# -*- encoding: utf-8 -*-
from selenium import webdriver
import time
def road_open():
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument(" -no-sandbox") # Chrome 无法打开设置
# chrome_options.add_argument(
# r'--user-data-dir=C:\Users\Administrator\AppData\Local\Google\Chrome\User Data') # 设置个人Chrome浏览器账户信息
# chrome_options.add_argument(r'--profile-directory=Default') # 配置文件
browser = webdriver.Chrome(options=chrome_options)
# browser = webdriver.Chrome(r'D:\software\Python\Python37-32\Scripts\chromedriver.exe') # 打开浏览器
browser.maximize_window() # 浏览最大化
browser.get('https://www.amap.com/search?id=B001913DXL&city=320102&geoobj=117.791254%7C31.495435%7C120.301377%7C32.628466&query_type=IDQ&query=%E8%8B%8F%E5%AE%81%E6%98%93%E8%B4%AD%E6%80%BB%E9%83%A8&zoom=9.66')
time.sleep(5)
while True:
browser.find_element_by_xpath("//*[@id='layerbox_item']/div[1]/a[3]").click()
browser.get_screenshot_as_file(r'gaode%s.png' % time.strftime('%Y-%m-%d-%H-%M-%S',time.localtime(time.time())))
print r'map\gaode%s.png' % time.strftime('%Y-%m-%d-%H-%M-%S',time.localtime(time.time()))
print browser.title
# 重复打开容易出现喝口水
browser.find_element_by_xpath("//*[@id='layerbox_item']/div[1]/a[3]").click()
# 隔多久执行一次
time.sleep(10)
browser.quit()
if __name__ == '__main__':
road_open()
网友评论