【发布时间】:2018-03-25 20:00:27
【问题描述】:
我在用漂亮的汤在网上抓取一些数据时遇到了一些问题,我想知道你们中的任何抓取器专家是否可以给我一些指导。
这是我要抓取的确切网页: https://coinmarketcap.com/currencies/bitcoin/historical-data/?start=20130428&end=20171013
具体来说,我想获取历史价格表并以某种方式将信息提取到 DataFrame 中。但首先我需要在原始 html 中实际找到它。
import requests
from bs4 import BeautifulSoup
data = requests.get('https://coinmarketcap.com/currencies/bitcoin/historical-data/?start=20130428&end=20171013')
soup = BeautifulSoup(data._content, 'html.parser')
很遗憾,我遇到了编码错误
UnicodeEncodeError: 'ascii' codec can't encode character '\xa0' in position 22075: ordinal not in range(128)
在将原始 html 传递给漂亮的汤之前,有没有办法基本上只是去掉所有无法编码的字符?
【问题讨论】:
标签: python web-scraping beautifulsoup