2022年 11月 13日

使用python访问网页并填写信息(登录)进行提交操作

使用python访问网页并填写信息(登录)进行提交操作

①例如这样的xpath( ‘//*[@id=“kw”]’)可以点击F12打开浏览器调试器(或者右键页面选择检查)=》点击调试器的箭头标志=》点击页面需要输入信息的input框或者点击提交的button按钮=》右键copy=》copy xpath即可
在这里插入图片描述
在这里插入图片描述

# from selenium import webdriver

# #打开谷歌浏览器
# driver = webdriver.Chrome()
# #打开百度搜索主页
# driver.get('https://www.baidu.com')
# driver.find_element_by_xpath('//*[@id="kw"]').send_keys('爱奇艺')
# driver.find_element_by_xpath('//*[@id="su"]').click()


from selenium import webdriver
import time

driver =webdriver.Chrome()
driver.get('https://passport.zhihuishu.com/login?service=https://onlineservice.zhihuishu.com/login/gologin')
time.sleep(3)
#send_keys设置input框内容  click处理点击
driver.find_element_by_xpath('//*[@id="lUsername"]').send_keys('账号') 
driver.find_element_by_xpath('//*[@id="lPassword"]').send_keys('密码')
driver.find_element_by_xpath('//*[@id="f_sign_up"]/div[1]/span').click()
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20