我正在尝试从链接的搜索页面获取公司的行业信息。我使用Chrome的开发工具获取xpath表单,但它会返回空括号。这里似乎是什么问题?lxml找不到Chrome提供的xpath?
from lxml import html
import requests
page = requests.get('https://www.linkedin.com/search/results/companies/?keywords=cisco.com')
tree = html.fromstring(page.content)
industry = tree.xpath('//*[@id="ember3734"]/div/div[1]/p[1]')
print(industry)
非常感谢!我可以使用任何驱动程序还是必须使用PhantomJS? – opamp
我认为Phantomjs更好,但是是个人意见。你将会得到与Firefox或谷歌浏览器相同的结果。但我认为phantomjs更轻。 – wu4m4n
@opamp您可以使用此https://gist.github.com/Wu4m4n/597367d32e443b9fe120f47d78d56bce安装phantomjs – wu4m4n