Python 从Beautifulsoup4获取字符串时出现问题
这是我的代码,我正在努力工作Python 从Beautifulsoup4获取字符串时出现问题,python,web-scraping,beautifulsoup,anaconda,Python,Web Scraping,Beautifulsoup,Anaconda,这是我的代码,我正在努力工作 import requests from bs4 import BeautifulSoup url = 'https://digitalcoinprice.com' source_code = requests.get(url) plain_text = source_code.text soup = BeautifulSoup(plain_text, "html.parser") for link in soup.find_all('a', {'class'
import requests
from bs4 import BeautifulSoup
url = 'https://digitalcoinprice.com'
source_code = requests.get(url)
plain_text = source_code.text
soup = BeautifulSoup(plain_text, "html.parser")
for link in soup.find_all('a', {'class': 'coin_currency_name'}):
title = link.string
print(title)
我的最终目标是创建一个网络爬虫,每5分钟记录前100名加密货币的信息。我很想解决这个问题,但我正在努力克服这个障碍。当我跑的时候
python wcrawl.py
它所做的只是移动到我可以键入新命令的位置。。。。很抱歉,我对这个主题了解不够,无法提供更多细节,我已经使用python整整12个小时了
更多信息:
视窗10
内部Anaconda命令提示符
Python3.7.2您可以使用pandas并阅读html
import pandas as pd
tables = pd.read_html('https://digitalcoinprice.com/')
print(tables[0])
如果大量考虑使用
,你应该找到“跨度”标签而不是“a”标签。import requests
from bs4 import BeautifulSoup
url = 'https://digitalcoinprice.com'
source_code = requests.get(url)
plain_text = source_code.text
soup = BeautifulSoup(plain_text, "html.parser")
for link in soup.find_all('span', {'class': 'coin_currency_name'}):
title = link.string
print(title)
它移动到您可以键入的位置,我想您的意思是您的脚本不输出任何内容并退出。换句话说,汤没有找到你给的文字。试试一些很明显的标签,例如:或某事。这个很好用。现在我正在将这些信息输入到csv文件中。。。。这是一个全新的挑战。