【发布时间】:2016-12-27 08:26:46
【问题描述】:
我正在尝试从here 获取联系人姓名,但我遇到了一个非常奇怪的问题。内容在浏览器中可见,但是当我使用 selenium 使用 xpath 查找元素时,我没有得到任何数据。只要我点击检查元素,selenium 就会找到数据。
mydriver = webdriver.Chrome()
print 'Webdriver Started'
mydriver.get('http://listings.fta-companies-au.com/l/101662595/BNP-Paribas-in-Sydney-NSW')
contact_persons = mydriver.find_elements_by_xpath('//div[@class="data-block is-editable no-header"]//div[@class="srp-float-wrap flt-scroll-wrap"]//table[@class="srp-widget-table"]/tbody/tr')
for p in contact_persons:
print p.text
当我只是加载并尝试查找数据时,它会返回一个空列表,但只要我点击检查元素,我就会得到所需的数据。
我也尝试过使用 requests 和 lxml 进行解析,但它们也返回空数据。
【问题讨论】:
标签: python-2.7 selenium xpath web-scraping