这里是交易,我有一些sinopse采取了从IMDB网站,但sinopse元素是在一个盒子里没有任何跟踪(如下图),我是这样尝试的,但我不知道如何提取文本,获得_属性或类似的东西。你知道吗
这就是工作版本
from selenium import webdriver
from selenium.webdriver.common.by import By
driver = webdriver.Chrome()
driver.get('http://www.imdb.com/title/tt2731500/')
alo = driver.find_element(By.XPATH, '//div[@itemprop="description"]').text
print(alo)
1)将html保存到磁盘
2)获得一个xml工具,比如xmllint和一堆关于XPath的好教程。你知道吗
3)测试和调试XPath,直到找到解决方案。你知道吗
4)如果您有关于XPath的具体问题,请在这里提问。你知道吗
假设你感兴趣的元素是
所以xpath可能是
//div[@itemprop="description"]
或者是英文版的
//div[@itemprop="description"]/p/text()
相关问题 更多 >
编程相关推荐