当前位置:网站首页>使用cookie登录百度网盘(网站使用cookie)
使用cookie登录百度网盘(网站使用cookie)
2022-07-25 19:59:00 【全栈程序员站长】
大家好,又见面了,我是你们的朋友全栈君。
cookies2.txt 为存放 cookie 字符串的文件。
cookie 字符串获取方式
1. 可以通过手动的方式去取,比如登录之后在 console 里面执行 document.cookie 即可获得
2. 在 application 里面查看 cookie 的值
3. 通过 webdriver.Chrome(…) 创建出来的实例,调用 get_cookies() 就可以获取到
from selenium import webdriver # 从selenium导入webdriver
import os
import platform
import traceback
import time
import pickle
BASE_PATH = os.path.abspath(os.path.dirname(__file__))
if platform.system() == 'Darwin':
wd = webdriver.Chrome('chromedriver') # Optional argument, if not specified will search path.
else:
wd = webdriver.Chrome(
os.path.join(BASE_PATH, 'chromedriver.exe')) # Optional argument, if not specified will search path.
url = 'https://zhidao.baidu.com/'
print(url)
wd.get(url)
cookie_path = os.path.join(BASE_PATH,'cookies2.txt')
readPath = open(cookie_path , 'r', encoding = 'utf-8')
BDCookies = readPath.read()
readPath.close()
allitem = BDCookies.split(';')
for item in allitem:
pair = item.split('=')
print('the pair ===> ', pair)
if pair and len(pair) == 2:
cookie = pair[0].lstrip()
value = pair[1]
try:
print(f'try add cookie "{cookie}"="{value}""')
wd.add_cookie({
"domain": "zhidao.baidu.com",
"name": cookie,
"value": value,
"path": '/',
"expires": None
})
except Exception as e:
traceback.print_exc()
wd.get("https://zhidao.baidu.com")
time.sleep(30)
wd.close()
del wd发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/127741.html原文链接:https://javaforall.cn
边栏推荐
- Split very long line of words into separate lines of max length
- Deeplobv1 and V2
- Amrita Institute of Engineering | reinforcement active learning method for optimizing sampling in terms extraction of emotional analysis
- Pytorch's transforms (numpy data type is converted to tensor, normalized and resized)
- 谷歌Pixel 6a屏下指纹扫描仪存在重大安全漏洞
- What is the method to load the torch pre trained model for the mindspore model finetune?
- 导电滑环在机械设备方面的应用
- On interface encryption
- The JS paging plug-in supports tables, lists, text, and images
- Detailed evaluation of current popular redis visual management tools
猜你喜欢

PMP practice once a day | don't get lost in the exam -7.25

The JS paging plug-in supports tables, lists, text, and images

【神器】截图+贴图工具 Snipaste

参与开源社区还有证书拿?

手机端触摸图片slider轮播插件photoswipe.js

给容器添加3d效果的副标题

随机梯度下降法、牛顿法、冲量法、AdaGrad、RMSprop以及Adam优化过程和理解

Univariate function integration_ Partial integral method

分享 25 个有用的 JS 单行代码

Is there a "fingerprint" in the structure of AAAI 2022 | Gan? Generating network structure from forged image traceability
随机推荐
Detailed explanation of three methods of selenium setting element waiting
PreScan快速入门到精通第十八讲之PreScan轨迹编辑的特殊功能
随机梯度下降法、牛顿法、冲量法、AdaGrad、RMSprop以及Adam优化过程和理解
Univariate function integration_ Partial integral method
Day7: ordered binary tree (binary search tree)
Mindspore1.1.1 source code compilation and installation -- errors in the core compilation stage
Application of conductive slip ring in mechanical equipment
Software designer afternoon real topic: 2009-2022
Three skills of interface request merging, and the performance is directly exploded!
Typeerror: 'STR' object is not callable error reason
10. < tag dynamic programming and subsequence, subarray> lt.53. maximum subarray and + lt.392. Judge subsequence DBC
Creative drop-down multi choice JS plug-in download
Analysis of CMS station building system of common PHP in China
手机端触摸图片slider轮播插件photoswipe.js
Pytorch's transforms (numpy data type is converted to tensor, normalized and resized)
国内常见php的CMS建站系统情况分析
C语言学习日记3——realloc函数
03 isomorphism of tree 1
Research and application of servo driver in robot
[good book recommendation] - authoritative guide to Ethernet (2nd Edition)