Python爬虫自动化抓取违章信息
#coding:utf-8
#import scrapy
from selenium import webdriver
from selenium.webdriver.support.select import Select
import time
import datetime
driver = webdriver.Firefox()
xnyNos = []
class AH122(object):
def login(self,num,pwd):
driver.get(‘https://ah.122.gov.cn/m/login?t=2′)
print(“打开登录页面,请输入密码并登录”)
time.sleep(60)
def fetch_XnyNos(self):
driver.get(“https://ah.122.gov.cn/views/memfyy/”)
print(“机动车管理”)
time.sleep(4)
sel = driver.find_element_by_xpath(“//select[@class=’switch’]”)
Select(sel).select_by_value(‘3′)
print(“选择非营运”)
time.sleep(4)
driver.find_element_by_xpath(“//li[@id=’sidebar_menu_7′]/a”).click()
time.sleep(4)
print(“选择小型新能源”)
sel = driver.find_element_by_id(“hpzl”)
Select(sel).select_by_value(’52’)
t