当前位置:网站首页>使用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
边栏推荐
- Wechat applet 10 - wechat template
- Three skills of interface request merging, and the performance is directly exploded!
- CarSim仿真快速入门(十四)—CarSim-Simulink联合仿真
- Siemens PLM Teamcenter download, installation and use tutorial
- C language learning diary 3 - realloc function
- [artifact] screenshot + mapping tool snipaste
- VMware virtual machine download, installation and use tutorial
- 【神器】截图+贴图工具 Snipaste
- RepVGG网络中重参化网络结构解读【附代码】
- PMP practice once a day | don't get lost in the exam -7.25
猜你喜欢

wallys//wifi6 wifi5 router IPQ6018 IPQ4019 IPQ4029 802.11ax 802.11ac
![[mindspore] [read graph data] cannot read mindrecord format graph data](/img/2a/6da73178993f3d0f84c1f6ada17884.png)
[mindspore] [read graph data] cannot read mindrecord format graph data

「分享」DevExpress ASP.NET v22.1最新版本系统环境配置要求

Wechat applet 10 - wechat template

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

创意下拉多选js插件下载

Rainbow plug-in extension: monitor MySQL based on MySQL exporter

Concept of IP address

C语言学习日记3——realloc函数

How to set tiktok mobile network environment? How can tiktok break the playback volume?
随机推荐
How to ensure the quality of customized slip rings
Yyds dry inventory how to locate browser page crash
Prescan quick start to master the special functions of prescan track editing in lecture 18
Shopping guide for high-end flagship projectors: dangbei X3 pro and dangbei F5 are more immersive!
Mobile phone touch picture slider rotation plug-in photoswipe.js
LP dual currency pledge liquidity mining DAPP system development logic analysis
给容器添加3d效果的副标题
Distributed link logging minbox logging usage document
Add a subtitle of 3D effect to the container
Application of conductive slip ring in mechanical equipment
Stochastic gradient descent method, Newton method, impulse method, adagrad, rmsprop and Adam optimization process and understanding
Bash does not add single quotes to your string
Authorized wireless communication standard
CarSim仿真快速入门(十五)—CarSim传感器仿真之ADAS Sensor Objects (1)
Oracle database download, installation, use tutorial and problem summary
软件设计师下午真题:2009-2022
"Share" devaxpress asp Net v22.1 latest version system environment configuration requirements
wallys//IPQ5018/IPQ6010/PD-60 802.3AT Input Output 10/100/1000M
参与开源社区还有证书拿?
Interpretation of repartitioned network structure in repvgg network [with code]