[英]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我说的地图截图
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.