简体   繁体   中英

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

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. 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. I am trying to use Python (BeautifulSoup and 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.

Well, you could move the mouse around via ActionChains on the canvas, but probably want the data (and not complicating things).

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM