发布时间: 2023-5-25 文章作者: myluzh 分类名称: Python 朗读文章
import time from selenium.webdriver import Chrome, ChromeOptions options = ChromeOptions() options.add_argument("--headless") driver = Chrome(options=options) driver.execute_cdp_cmd( "Browser.grantPermissions", { "origin": "https://www.openstreetmap.org/", "permissions": ["geolocation"] }, ) driver.execute_cdp_cmd( "Emulation.setGeolocationOverride", { "latitude": 35.689487, "longitude": 139.691706, "accuracy": 100, }, ) driver.get("https://www.openstreetmap.org/") driver.find_element_by_xpath("//span[@class='icon geolocate']").click() time.sleep(3) # wait for the page full loaded driver.get_screenshot_as_file("screenshot.png")
标签: selenium Chrome 传感器 位置 虚拟定位
发表评论