自动启动浏览器联网

1,安装相应的python库

2,下载 edge 浏览器驱动 weddriver

 

python 文件转成exe文件

Python 生成exe程序_python生成exe_minky糕的博客-CSDN博客 

 

参考链接

编写python代码实现打开并登录网页、对网页进行点击、输入信息等操作_python 操作网页_shiaohan的博客-CSDN博客

 python模拟打开Edge浏览器并打开网页(selenium+edge)_z54572的博客-CSDN博客

Python报错:AttributeError: ‘WebDriver‘ object has no attribute ‘find_element_by_link_text‘ 解决_PatrickYuc的博客-CSDN博客

 

 

代码

## 2023/8/26 ghzhan
## 通过"本地上网账号认证" 方式登录

from time import sleep
from selenium import webdriver  # 引入模块
import ping3

##### 判断网络连接
response = ping3.ping("www.baidu.com", timeout=5)
if response:
    print('Your network has been connected, no need to connect again!')
    sleep(5)
    exit()
else:
    print("Connecting to the network ...")
####

driver = webdriver.Edge()
driver.get("https://wired.ime.ac.cn/") 
driver.find_element('xpath','//*[@id="app"]/section/div[2]/div[2]/div[3]/button').click()
sleep(10)
driver.find_element('xpath','//*[@id="username"]').send_keys('xxxx')
driver.find_element('xpath','//*[@id="password"]').send_keys('xxxx')
driver.find_element('xpath','//*[@id="login-account"]').click()
sleep(60)

 

posted @ 2023-08-26 14:57  ghzphy  阅读(30)  评论(0编辑  收藏  举报