当前位置:网站首页>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
边栏推荐
- VMware 虚拟机下载、安装和使用教程
- Recommendations on how to install plug-ins and baby plug-ins in idea
- A high efficiency 0-delay 0-copy QT player scheme based on Hisilicon 3559
- Security Basics 4 - regular expressions
- Selenium runs slowly - speed up by setting selenium load policy
- 4. Server startup of source code analysis of Nacos configuration center
- Three skills of interface request merging, and the performance is directly exploded!
- VMware virtual machine download, installation and use tutorial
- wallys//IPQ5018/IPQ6010/PD-60 802.3AT Input Output 10/100/1000M
- PMP每日一练 | 考试不迷路-7.25
猜你喜欢
![Partial interpretation of yolov7 paper [including my own understanding]](/img/80/95d00565c4ec89a388ae4386801a02.png)
Partial interpretation of yolov7 paper [including my own understanding]

When AI encounters life and health, Huawei cloud builds three bridges for them
![[artifact] screenshot + mapping tool snipaste](/img/d2/a9a706a114641094e32ab5c6193f58.png)
[artifact] screenshot + mapping tool snipaste

Security Basics 4 - regular expressions
![[cloud native | learn kubernetes from scratch] VIII. Namespace resource quotas and labels](/img/7e/2bdead512ba5bf5ccd0830b0f9b0f2.png)
[cloud native | learn kubernetes from scratch] VIII. Namespace resource quotas and labels

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

如何保证定制滑环质量

Connecting to the database warning establishing SSL connection without server's identity verification is not recommended

Day7: ordered binary tree (binary search tree)

Research and application of servo driver in robot
随机推荐
Analysis of CMS station building system of common PHP in China
Split very long line of words into separate lines of max length
随机梯度下降法、牛顿法、冲量法、AdaGrad、RMSprop以及Adam优化过程和理解
Recommended system topic | Minet: cross domain CTR prediction
Six axis sensor use learning record
Detailed evaluation of current popular redis visual management tools
基于海思3559 高效率的 0延时 0拷贝 qt播放器方案
JVM(二十三) -- JVM运行时参数
Connecting to the database warning establishing SSL connection without server's identity verification is not recommended
数字信息化(先枚举假设,再看是否满足条件)(1089 狼人杀-简单版)
Is there a "fingerprint" in the structure of AAAI 2022 | Gan? Generating network structure from forged image traceability
Share 25 useful JS single line codes
一元函数积分学_分部积分法
Interpretation of repartitioned network structure in repvgg network [with code]
Prescan quick start to master Lesson 19: prescan actuator configuration, track synchronization and non configuration of multiple tracks
Common misunderstandings caused by a time reporting assistant of Blue Bridge Cup basic questions
UNET and mask RCNN
Binarysearch basic binary search
统信UOS下配置安装cocos2dx开发环境
sentinel简单限流和降级demo问题记录