我正试图从这个网页上抓取图表数据https://www.focusireland.ie/resource-hub/latest-figures-homelessness-ireland/
在右上方,有一个图表详细说明了爱尔兰无家可归者的数量。在
我试着在网上划出轴,它是Jul-14和它对应的值3258。但是,我无法使用x路径定位这些元素及其值。在
我试过这样的方法来获取价值
Val1 = driver.find_element_by_xpath("//*[@id='chart']/div[7]").text
没用。在
试过了这:在
^{pr2}$它对我也不起作用,并返回错误消息作为
Unable to locate an element with the xpath expression //div[@class='label series smaller' | @class='label series smaller hover']/span[text()='Jul-14' because of the following error:
SyntaxError: Failed to execute 'evaluate' on 'Document': The string '//div[@class='label series smaller' | @class='label series smaller hover']/span[text()='Jul-14'' is not a valid XPath expression.
您可以尝试以下代码获取文本:
元素\u到\u悬停_超过.text在
您的第二张图表在框架内,首先您需要切换到框架中:-
^{pr2}$然后尝试在xpath下面获取列表中的值
然后遍历每一行并获取值
数据不在那个网站上。您必须解析图表()的源iframe数据包装器.dwcdn.net/** ). 然后必须提取并解析JS变量(__数据仓库参数数据). 在
这并不难,see this。在
相关问题 更多 >
编程相关推荐