我试图刮一个网页(“coinmarketcap”)。我正在搜集2013年至2019年10月所有加密货币的数据(开盘、高点、低点、收盘、市值、成交量)。你知道吗
for j in range (0,name_size):
url = ("https://coinmarketcap.com/currencies/" + str(name[j]) + "/historical-data/?start=20130429&end=20191016")
page = urllib.request.urlopen(url)
soup = BeautifulSoup(page, 'html.parser')
priceDiv = soup.find('div', attrs={'class':'table-responsive'})
rows = priceDiv.find_all('tr')
问题是某个url不存在。我不知道如何跳过这些。你能帮帮我吗?你知道吗
使用错误捕获。你知道吗
出错的将被打印消息跳过,否则任务将继续
使用
try-except
相关问题 更多 >
编程相关推荐