我是python的新用户,我想从以下网站获取数据:https://www.telerad.be/Html5Viewer/index.html?viewer=telerad_fr
我的问题是数据是动态生成的。我读到很少有可能修复,但没有一个是令人满意的。对于selenium,我需要一个名称或Xpath
来单击按钮,但这里什么都没有。你知道吗
import requests
from lxml import html
page = requests.get('https://www.telerad.be/Html5Viewer/index.html?viewer=telerad_fr')
tree = html.fromstring(page.content)
cities = tree.xpath('//*[@id="map-container"]/div[6]/div[2]/div/div[2]/div/div/div[1]/div/p[1]/text()[2]')
print('Cities: ', cities)
实际上有一个xpath可以点击按钮:
来,试试这个(硒):
这段代码单击(或者至少尝试,如果没有StaleElementExceptions发生)地图上的所有橙色点,并打印“Cities”内容(基于Xpath)。你知道吗
如果有人在代码中发现错误,请编辑这个答案,我写在记事本++。你知道吗
相关问题 更多 >
编程相关推荐