当前位置:网站首页>Browser cookie to selenium cookie login
Browser cookie to selenium cookie login
2022-06-27 12:22:00 【Yu rabbit】
python Use selenium Simulation operation Chrome browser ,cookie The addition of
webdriver download
chrome Browser driven
http://chromedriver.storage.googleapis.com/index.html
Find the corresponding driver and download it .
Get ready cookie
I got it from the browser, as shown in the figure :
import time
from selenium import webdriver
cookie = 'uuid_tt_dd=10_19093309300-1614257743141-276654; UN=yutu75; Hm_ct_6bcd52f51e9b3dce32bec4a3997715ac=6525*1*10_19093309300-1614257743141-276654!5744*1*yutu75; _ga=GA1.2.663410303.1614267961; __gads=ID=95dd03f56e1370d0-22571a531fca005d:T=1625409214:RT=1625409214:S=ALNI_MY-aWM9Zr2zrKvEuliojR5MyBUkvg; UserName=yutu75; UserInfo=9eeb838640814c459d2eb06c2429558f; UserToksssssue%22%3A%221%22%2C%22scope%22%3A1%7D%2C%22isonline%22%3A%7B%22value%22%3A%221%22%2C%22scope%22%3A1%7D%2C%22isvip%22%3A%7B%22value%22%3A%220%22%2C%22scope%22%3A1%7D%2C%22uid_%22%3A%7B%22value%22%3A%22yutu75%22%2C%22scope%22%3A1%7D%7D; Hm_lvt_e5ef47b9f471504959267fd614d579cd=1650853482,1653295631; management_ques=1653996231708; c_dl_prid=1654683664939_325152; c_dl_rid=1654781258952_148261; c_dl_fref=https://www.baidu.com/link; c_dl_fpage=/download/weixin_42098251/18445929; c_dl_um=-; historyList-new=%5B%22%E5%B0%8F%E7%B1%B3%E6%89%8B%E6%9C%BA%E5%88%B7%E9%B8%BF%E8%92%99%E7%B3%BB%E7%BB%9F%22%5D; FCNEC=[["AKsRol_6zPNvPIPgBuo9ajx1VkA0uJY4Cw-C2xSpr7-tCPqfuVbUKo1VrlCXXMP84-3sXal_NRQ1yN2uM7n1aNiPiyLPd9ccSd-id4OqQfGL8kiEIM5TIo-o1UcZ7r0tL0oE-cvAmFYB-jMclYhtemkQ8GcBanOfUg=="],null,[]]; dc_session_id=10_1655985521086.882045; firstDie=1; __gpi=UID=0000050dec0d6a33:T=1651075728:RT=1655985931:S=ALNI_MYRr0bDHGBvHVc2YzfX6gM9FFjNuA; dc_sid=9a353d315b813af0fdbfdade80aea75c; c_segment=14; Hm_lvt_6bcd52f51e9b3dce32bec4a3997715ac=1655801615,1655887598,1655985522,1655986686; c_first_ref=default; c_first_page=https%3A//mp.csdn.net/%3Fspm%3D1010.2135.3001.4503; c_dsid=11_1655989376923.788455; c_page_id=default; c_pref=https%3A//mp.csdn.net/mp_blog/manage/article%3Fspm%3D1003.2000.3001.5448; c_ref=https%3A//mp.csdn.net/mp_blog/manage/article%3Fspm%3D1011.2415.3001.5448; dc_tos=rdxm31; log_Id_pv=1013; Hm_lpvt_6bcd52f51e9b3dce32bec4a3997715ac=1655990030; log_Id_view=3024; log_Id_click=553'
url = f'https://blog.csdn.net/nav/python'
webdriver_path = r'C:\Users\xiao3\Desktop\selenium\chromedriver.exe'
def get_cookie_list():
""" :param : From the browser cv Or go from requests What we got in cookie :return: Retroflex cookie list """
cookie_list = []
for i in cookie.split(';'):
i_dict = {
'name': i.split('=')[0].strip(), 'value': i.split('=')[1].strip()}
cookie_list.append(i_dict)
return cookie_list
def main():
try:
driver = webdriver.Chrome(webdriver_path)
driver.get(url)
time.sleep(1)
cookie_list = get_cookie_list()
for c_i in cookie_list:
driver.add_cookie(c_i)
time.sleep(1)
driver.get(url)
time.sleep(5)
driver.close()
driver.quit()
except Exception as e:
print(e)
driver.quit()
if __name__ == '__main__':
main()
Result chart :
边栏推荐
- 今晚战码先锋润和赛道第2期直播丨如何参与OpenHarmony代码贡献
- Interviewer: with the for loop, why do you need foreach?
- Maximum path and problem (cherry picking problem)
- StarCraft's Bug King ia retired for 2 years to engage in AI, and lamented that it was inferior
- pull request
- alibaba jarslink
- 2022ciscn central China Web
- Wechat applet realizes five-star evaluation
- R language dplyr package arrange function sorts dataframe data, sorts dataframe data through multiple data columns, specifies the first field to be sorted in descending order, and does not specify the
- ACL 2022 | 中科院提出TAMT:TAMT:通过下游任务无关掩码训练搜索可迁移的BERT子网络
猜你喜欢

dried food! What problems will the intelligent management of retail industry encounter? It is enough to understand this article

Safe landing practice of software supply chain under salesforce containerized ISV scenario

uni-app开发微信小程序动态渲染页面,动态改变页面组件模块顺序

浏览器cookie转selenium cookie登录
![Dynamic programming [III] (interval DP) stone merging](/img/a4/82c4d63b8df5d092a96b80dd497147.jpg)
Dynamic programming [III] (interval DP) stone merging

DM8:达梦数据库-锁超时

Rxjs mergeMap 的使用场合

如何修改 node_modules 里的文件

mysql学习1:安装mysql

Interviewer: with the for loop, why do you need foreach?
随机推荐
Topic37——64. 最小路径和
深入理解 happens-before 原则
【面试高频题】难度 1.5/5,LCS 模板题
R language uses the poisgof function of epidisplay package to test the goodness of fit of Poisson regression and whether there is overdispersion
记一次 .NET 某物管后台服务 卡死分析
Hands on API development
Basic usage and principle of fork/join framework
C# wpf 实现撤销重做功能
Deep understanding of happens before principle
R language uses GLM function to build Poisson logarithm linear regression model, processes three-dimensional contingency table data to build saturation model, uses step function to realize stepwise re
Shell script learning notes
一个有趣的网络掩码的实验
Drive to APasS! Use Mingdao cloud to manage F1 events
Time management understood after being urged to work at home
uniapp下拉弹层选择框效果demo(整理)
Object serialization
C # WPF realizes undo redo function
如何修改 node_modules 裏的文件
1. Mx6ull startup mode
Nifi from introduction to practice (nanny level tutorial) - identity authentication