当前位置:网站首页>Log in to Baidu online disk with cookies (websites use cookies)
Log in to Baidu online disk with cookies (websites use cookies)
2022-07-25 19:59:00 【Full stack programmer webmaster】
Hello everyone , I meet you again , I'm your friend, Quan Jun .
cookies2.txt For storage cookie String file .
cookie String acquisition method
1. You can get it manually , For example, after logging in console It's executed inside document.cookie You can get
2. stay application Inside view cookie Value
3. adopt webdriver.Chrome(…) Created instance , call get_cookies() I can get it
from selenium import webdriver # from selenium Import 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 wdPublisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/127741.html Link to the original text :https://javaforall.cn
边栏推荐
- How to get started quickly in software testing
- The use of new promise, async and await in the project, and the practical application of promise.all in the project
- [wp]ctfshow-web getting started - Explosion
- Bash does not add single quotes to your string
- 【好书推荐】-- 《以太网权威指南》(第2版)
- Export and call of onnx file of pytorch model
- [Infographics Show] 248 Public Domain Name
- Sentinel simple current limiting and degradation demo problem record
- what is qml in qt
- 谷歌Pixel 6a屏下指纹扫描仪存在重大安全漏洞
猜你喜欢

Six axis sensor use learning record

4. Server startup of source code analysis of Nacos configuration center

Stochastic gradient descent method, Newton method, impulse method, adagrad, rmsprop and Adam optimization process and understanding

Illegal mix of collations for operation ‘UNION‘(bug记录)
![[mindspore] [read graph data] cannot read mindrecord format graph data](/img/2a/6da73178993f3d0f84c1f6ada17884.png)
[mindspore] [read graph data] cannot read mindrecord format graph data

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

How to get started quickly in software testing

Export and call of onnx file of pytorch model

wallys//IPQ5018/IPQ6010/PD-60 802.3AT Input Output 10/100/1000M

Day7:有序二叉树(二叉搜索树)
随机推荐
How to get started quickly in software testing
Bash does not add single quotes to your string
Split very long line of words into separate lines of max length
什么是唯心主义
what is qml in qt
从瞳代到“瞳代”再到品牌,暴利的美瞳的变与未变
[wp]ctfshow-web introductory information collection
When the V100 of mindpole 8 card is trained to 101 epochs, an error of reading data timeout is reported
创意下拉多选js插件下载
The JS paging plug-in supports tables, lists, text, and images
919. 完全二叉树插入器
滑雪手机端H5小游戏源码下载
On interface encryption
国内常见php的CMS建站系统情况分析
【神器】截图+贴图工具 Snipaste
JVM (XXIII) -- JVM runtime parameters
Mutual conversion of camera internal parameter matrix K and FOV
PMP practice once a day | don't get lost in the exam -7.25
「分享」DevExpress ASP.NET v22.1最新版本系统环境配置要求
软件设计师下午真题:2009-2022