day1 UnicodeEncodeError: 'gbk' codec can't encode character '\xa0' in position 2490: illegal multi...

get方式得到网页的信息

  day1 UnicodeEncodeError: 'gbk' codec can't encode character '\xa0' in position 2490: illegal multi..._第1张图片

 

#coding=utf-8
#pip install requests

#直接get到网页的信息
import requests
from bs4 import BeautifulSoup

response = requests.get('https://www.sogou.com/web?query=搞基建')
print(response.text)  #打印搜索出来的全部信息

#从 response.text  找出   

 

  day1 UnicodeEncodeError: 'gbk' codec can't encode character '\xa0' in position 2490: illegal multi..._第2张图片

 

 

2.编码格式不对

  day1 UnicodeEncodeError: 'gbk' codec can't encode character '\xa0' in position 2490: illegal multi..._第3张图片

 

3.全部改为utf-8

   day1 UnicodeEncodeError: 'gbk' codec can't encode character '\xa0' in position 2490: illegal multi..._第4张图片

 

4.执行成功

  day1 UnicodeEncodeError: 'gbk' codec can't encode character '\xa0' in position 2490: illegal multi..._第5张图片

 

转载于:https://www.cnblogs.com/venicid/p/7608181.html

你可能感兴趣的:(day1 UnicodeEncodeError: 'gbk' codec can't encode character '\xa0' in position 2490: illegal multi...)