我正试图从下面的网站上刮取硬币的名字
https://www.block123.com/en/nav/065285354703.htm
我已经拖网了堆栈溢出,但不明白为什么我没有得到
网站上的完整姓名列表。我不熟悉这一点,因此感谢所有人
帮助和耐心
url = 'https://www.block123.com/en/nav/065285354703.htm'
r = requests.get(url)
soup = BeautifulSoup(r.text, 'html.parser')
for coin in soup.find_all('div', attrs={'class':'portfolio-content item-content'}):
print(coin.find("div", attrs={"class":"name"}))
现在,我已经用selenium编写了一个scraper,使我能够输入密码信息
然后,我可以访问完整的投资组合详细信息,我已经刮去了所有的硬币,但也得到了许多相同类名的不需要的文本。
提供的答案中建议的代码非常有助于删除这些内容,因为它只包含在上一节中有“公文包”的元素
我不确定在使用selenium时如何应用此功能。如果您有任何帮助,我将不胜感激
driver.get(links['https://www.block123.com/en/nav/065285354703.htm'])
coins = driver.find_elements_by_class_name("portfolio-item")
coin_names = [coin.find_element_by_class_name('name').text for coin in coins]
检查带有
'class':'portfolio-content item-content'
的每个div
前面的<div>
是否包含文本Portfolio
,以确定div是否包含硬币,如果是,则提取硬币名称相关问题 更多 >
编程相关推荐