简体   繁体   English

如何使用 Python 在 HTML 页面上抓取仅在鼠标悬停在地图/图像部分上时显示的数据?

[英]How do I web scrape data on an HTML page that only shows up on a mouse hover over parts of a map/image using Python?

I am trying to scrape the following data from a map on this page: https://a816-dohbesp.nyc.gov/IndicatorPublic/AQHub/explorer.html我试图从这个页面上的地图中抓取以下数据: https : //a816-dohbesp.nyc.gov/IndicatorPublic/AQHub/explorer.html

Screenshot of the map I am talking about我说的地图截图

  • Groupings by the colors on the map (Low/Medium/High)按地图上的颜色分组(低/中/高)
  • Neighborhood names that show up on a mouse hover鼠标悬停时显示的社区名称

Question : How do I figure out which elements to scrape the data from?问题:如何确定要从哪些元素中抓取数据?

When I inspect the map, it points to this HTML code, but it doesn't seem to change when I move my cursor around the map.当我检查地图时,它指向这个 HTML 代码,但是当我在地图上移动光标时它似乎没有改变。 I can't seem to find an XPath for the text elements showing the individual names that pop up when you hover your mouse over the map.我似乎找不到文本元素的 XPath,显示当您将鼠标悬停在地图上时弹出的各个名称。 I am trying to use Python (BeautifulSoup and Selenium).我正在尝试使用 Python(BeautifulSoup 和 Selenium)。

 <canvas width="546" height="500" class="marks">

Ideally I'd like to end up with a spreadsheet that has the the following information like this:理想情况下,我希望最终得到一个包含以下信息的电子表格:

Neighborhood邻里 Building emissions建筑排放 Building density建筑密度 Industrial Area工业区 Traffic Density交通密度
Midtown-Midtown South中城-中城南 High高的 High高的 High高的 High高的

This is my first post on stackoverflow, so please let me know how I might better ask my question.这是我在 stackoverflow 上的第一篇文章,所以请告诉我如何更好地提出我的问题。

Well, you could move the mouse around via ActionChains on the canvas, but probably want the data (and not complicating things).好吧,您可以通过画布上的 ActionChains 移动鼠标,但可能需要数据(而不是使事情复杂化)。

Try: results = driver.execute_script("return nyccasData") .尝试: results = driver.execute_script("return nyccasData")

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 web 如何使用 python 美丽的汤刮取仅出现在鼠标 hover 上的数据? - How to web scrape data which only appears on mouse hover using python beautiful soup? 如何使用Python从html表中通过Web抓取数据并将其存储在csv文件中。 我可以提取某些部分,但不能提取其他部分 - How to web scrape data using Python from an html table and store it in a csv file. I am able to extract some parts but not the others 如何从通过 selenium 和 python 提交数据后刷新的网页中抓取数据? - How do I scrape data from a web page that refreshes after submitting data via selenium and python? 我如何只使用 praw 抓取图像 reddit 帖子? - How do i only scrape image reddit posts using praw? 如何使用 python 刮掉苹果 HTML 页面? - How can I scrape an apple HTML page using python? 如何使用python中的beautifulsoup从网页中获取数据 - How do I get scrape data from web pages using beautifulsoup in python 如何使用 Python 抓取多语言网页 - How do I scrape multi-language web using Python 当我使用 Python folium 库将鼠标悬停在世界地图上时,如何显示国家名称和人口? - How do I display country name and population when I hover over world map using Python folium library? 如何在没有看到要刮擦的代码的网页中以刮擦的方式获取数据 - How do I obtain data, with scrapy, in a web page in which I do not see that there is the code I want to scrape 如何使用Selenium和Python抓取嵌套数据 - How do I scrape nested data using selenium and Python>
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM