uniapp开发app框架在提升开发效率中的独特优势与应用探索
625
2022-11-21
【selenium】selenium和requests登陆的区别
requests登陆
import requestsimport timet = int(time.time()*1000)# 创建一个会话s = requests.Session()post_url = '= { 'username': 'xxxxxxxxx', 'password': 'xxxxxxxxx', '_token': 'nmSXhgHib8dTIC9DrATSkTzBBo4zz9eqDEPeG5i1', '_t': t}r = s.post(url=post_url, data=data,allow_redirects=False)r = s.get('open('chinaunix.html', 'w') as fp: fp.write(r.text)
selenium登陆
from selenium import webdriverimport timeurl = '= webdriver.Chrome()webdriver.get(url=url)time.sleep(15)webdriver.find_element_by_name('username').send_keys('xxxxxxxxx')webdriver.find_element_by_name('password').send_keys('xxxxxxxxx')webdriver.find_element_by_name('loginsubmit').click()time.sleep(15)with open('chinaunixselenium.html','w',encoding='utf-8') as fp: fp.write(webdriver.page_source)
使用Selenium 需要安装:pip install selenium -: 注:支持chromeV74版本的driver版本号比较特别一点,不知道之后会不会回归以前正常的版本ChromeDriver 78.0.3904.11 (2019-09-12)---------Supports Chrome version 78ChromeDriver 77.0.3865.40 (2019-08-20)---------Supports Chrome version 77ChromeDriver 76.0.3809.12 (2019-06-07)---------Supports Chrome version 76ChromeDriver 75.0.3770.8 (2019-04-29)---------Supports Chrome version 75ChromeDriver v74.0.3729.6 (2019-03-14)--------Supports Chrome v74ChromeDriver v2.46 (2019-02-01)----------Supports Chrome v71-73--------以下为2018年兼容版本对照表-------ChromeDriver v2.45 (2018-12-10)----------Supports Chrome v70-72ChromeDriver v2.44 (2018-11-19)----------Supports Chrome v69-71ChromeDriver v2.43 (2018-10-16)----------Supports Chrome v69-71ChromeDriver v2.42 (2018-09-13)----------Supports Chrome v68-70ChromeDriver v2.41 (2018-07-27)----------Supports Chrome v67-69ChromeDriver v2.40 (2018-06-07)----------Supports Chrome v66-68ChromeDriver v2.39 (2018-05-30)----------Supports Chrome v66-68ChromeDriver v2.38 (2018-04-17)----------Supports Chrome v65-67ChromeDriver v2.37 (2018-03-16)----------Supports Chrome v64-66ChromeDriver v2.36 (2018-03-02)----------Supports Chrome v63-65ChromeDriver v2.35 (2018-01-10)----------Supports Chrome v62-64
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~