安装python,安装时选中自动添加环境变量path
安装vscode和python插件
chrome开发包下载
http://npm.taobao.org/mirrors/chromedriver/
查看电脑chrome版本,找版本最详详尽的
拷贝到python安装包的Scripts文件夹下
然后参考下面代码
导入包
pip install selenium
from selenium import webdriver
from time import sleep
from selenium.webdriver.common.by import By
import time
username = "你的用户名"
password = "你的密码"
path = "D:/1.jpg"
EXECUTENUM = 0
#Page1
# 企业基本信息
if EXECUTENUM in (0,1):
time.sleep(1)
wd = webdriver.Chrome()
wd.implicitly_wait(2)
wd.get('http://218.11.12.99:9090/HeBeiQiYeYiFaPiLu/#/login')
input_wd = wd.find_element(By.XPATH,'//*[@id="login_warp"]/div[2]/div/div/form/div[1]/div/div[1]/div/input')
input_wd.send_keys(username)
input_wd = wd.find_element(By.XPATH,'//*[@id="login_warp"]/div[2]/div/div/form/div[2]/div/div/div/input')
input_wd.send_keys(password)
wd.find_element(By.XPATH, '//*[@id="login_warp"]/div[2]/div/div/form/div[3]/button').click()
wd.find_element(By.XPATH, '//*[@id="app"]/div/div[2]/section/div/div/div[2]/div[2]/div/div[3]/table/tbody/tr/td[5]/div/a').click()
print("企业基本信息")
time.sleep(7)
# time.sleep(4)
wd.find_element(By.XPATH, '//*[@id="pane-enterpriseBaseInfo"]/div/div[1]/div[3]/div[3]/button/span').click()
input_wd = wd.find_element(By.XPATH,'//*[@id="pane-enterpriseBaseInfo"]/div/div[2]/div/div[2]/div/form/div[1]/div/div/div/input')
input_wd.send_keys('生产工艺名称')
input_wd = wd.find_element(By.XPATH,'//*[@id="pane-enterpriseBaseInfo"]/div/div[2]/div/div[2]/div/form/div[2]/div/div/div/input')
input_wd.send_keys('主要产品与服务名称')
input_wd = wd.find_element(By.XPATH,'//*[@id="pane-enterpriseBaseInfo"]/div/div[2]/div/div[2]/div/form/div[3]/div/div/div/input')
input_wd.send_keys('限制类名录情况')
wd.find_element(By.XPATH, '//*[@id="pane-enterpriseBaseInfo"]/div/div[2]/div/div[3]/span/button[1]').click()
time.sleep(1)
wd.find_element(By.XPATH, '//*[@id="pane-enterpriseBaseInfo"]/div/div[1]/div[5]/button[1]').click()
time.sleep(5)
wd.quit()
time.sleep(5)
#Page2
#企业环境守法关键信息
if EXECUTENUM in (0,2):
time.sleep(1)
wd = webdriver.Chrome()
wd.implicitly_wait(2)
wd.get('http://218.11.12.99:9090/HeBeiQiYeYiFaPiLu/#/login')
input_wd = wd.find_element(By.XPATH,'//*[@id="login_warp"]/div[2]/div/div/form/div[1]/div/div[1]/div/input')
input_wd.send_keys(username)
input_wd = wd.find_element(By.XPATH,'//*[@id="login_warp"]/div[2]/div/div/form/div[2]/div/div/div/input')
input_wd.send_keys(password)
wd.find_element(By.XPATH, '//*[@id="login_warp"]/div[2]/div/div/form/div[3]/button').click()
wd.find_element(By.XPATH, '//*[@id="app"]/div/div[2]/section/div/div/div[2]/div[2]/div/div[3]/table/tbody/tr/td[5]/div/a').click()
print("企业环境守法关键信息")
time.sleep(5)
input_wd = wd.find_element(By.XPATH,'//*[@id="pane-lawCompliance"]/div/div/form/div[1]/div/div/div/textarea')
input_wd.send_keys('行政处罚,司法判决等情况')
input_wd = wd.find_element(By.XPATH,'//*[@id="pane-lawCompliance"]/div/div/form/div[2]/div/div/div/textarea')
input_wd.send_keys('生态环境许可变更情况')
input_wd = wd.find_element(By.XPATH,'//*[@id="pane-lawCompliance"]/div/div/form/div[3]/div/div/div/textarea')
input_wd.send_keys('污染排放情况')
input_wd = wd.find_element(By.XPATH,'//*[@id="pane-lawCompliance"]/div/div/form/div[4]/div/div/div/textarea')
input_wd.send_keys('关键环境信息')
wd.find_element(By.XPATH, '//*[@id="pane-lawCompliance"]/div/div/form/div[5]/button[1]').click()
time.sleep(5)
wd.quit()
time.sleep(5)