我试图从这个网站上列出所有排名前1000位的instagramer账户:“https://hypeauditor.com/top-instagram/”。 从lxml返回的列表对于两者都是空的lxml.html文件以及lxml.etree文件. 你知道吗
我试图删除tbody、delete text()和上面的xpath,但都失败了。 值得注意的是,使用上面的xpath,它确实返回了一些东西,但它几乎是/n
我第一次试过lxml.etree文件你知道吗
market_url='https://hypeauditor.com/top-instagram/'
r_market=requests.get(market_url)
s_market=etree.HTML(r_market)`
file_market=s_market.xpath('//*[@id="bloggers-top-table"]/tr[1]/td[3]/a/text()')
我也试过了lxml.html文件. 你知道吗
tree=html.fromstring(r_market.content)
result=tree.xpath('//*[@id="bloggers-top-table"]/tr/td/h4/text()')
此外,我还尝试了以下xpath:
s_market.xpath('//*[@id="bloggers-top-table"]/tbody/text()')
它没有给我任何错误。但是在所有的尝试之后,它还是给了我一个空列表还是一个满是n/的列表。你知道吗
我不是真正有经验的网页抓取,所以有可能我刚刚犯了一个愚蠢的错误,但由于没有数据,我无法启动我的机器学习模型,我真的很挣扎,请帮助。你知道吗
更简单的方法是使用
pandas
。它可以像这样读取简单的HTML表。请尝试以下代码来废弃整个表。你知道吗您肯定希望熟悉包BeautifulSoup,它允许您用python导航网页的内容。你知道吗
使用BeautifulSoup:
这里有一种更轻量级的方法,可以使用nth类型来获取该列。你应该快点找到。你知道吗
相关问题 更多 >
编程相关推荐