【问题标题】:Scraping pin coordinates from an interactive map with Selenium使用 Selenium 从交互式地图中抓取图钉坐标
【发布时间】:2020-08-11 15:09:43
【问题描述】:

我正在尝试在 this Interactive map 上刮掉掉落的针脚坐标。 该地图是用 Leaflet JavaScript 库制作的。它以某种方式获取坐标,但在网站本身上找不到此信息。

问题:如果我什至不知道 Selenium 在哪里,如何评估坐标信息?

为了节省一些时间:

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time

PATH = "..."
driver = webdriver.chrome(PATH)


driver.get("https://kaupunkipyorat.hsl.fi/en/helsinki/stations")
driver.quit()

谢谢!

【问题讨论】:

    标签: python-3.x selenium selenium-webdriver beautifulsoup


    【解决方案1】:

    页面向https://api.digitransit.fi/routing/v1/routers/hsl/bike_rental发出请求,其中包含您想要的信息。

    要获得前五个站点的名称,我们可以这样写:

    import requests
    response = requests.get("https://api.digitransit.fi/routing/v1/routers/hsl/bike_rental")
    json = response.json()
    for station in json["stations"][:5]:
         print(station["name"])
    

    哪些打印:

    Luhtimäki
    Petikontie
    Martinkyläntie
    Vantaanpuisto
    Vehkala station
    

    【讨论】:

    • 哇哦,非常感谢!请问你是怎么找到请求源的?
    猜你喜欢
    • 1970-01-01
    • 2015-08-12
    • 1970-01-01
    • 2019-04-26
    • 1970-01-01
    • 1970-01-01
    • 2021-07-01
    相关资源
    最近更新 更多