BeautifulSoup UnicodeEncodeError:ascii编解码器

时间:2017-04-30 18:08:48

标签: python beautifulsoup

我正在尝试使用BeautifulSoup进行一些解析:

from bs4 import BeautifulSoup
import requests
import lxml

r = requests.get('https://pythonprogramming.net/parsememcparseface/')

page_text = r.text.encode('utf-8').decode('ascii', 'ignore')

soup = BeautifulSoup(page_text, 'lxml')

print(soup.find_all('p'))

由于find_all('p'),我无法使用UnicodeEncodeError。打字只是汤.p很好。我使用变量page_text来编码html文件,但这还不够。如何克服此错误并访问网站上的所有段落?

0 个答案:

没有答案
相关问题