当前位置:网站首页>使用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
边栏推荐
- PMP每日一练 | 考试不迷路-7.25
- A high efficiency 0-delay 0-copy QT player scheme based on Hisilicon 3559
- Add a subtitle of 3D effect to the container
- 高数_第3章重积分 学习体会与总结
- Gbase 8s UDR memory management_ 02_ mi_ dalloc
- 9. < tag dynamic programming and subsequence, subarray> lt.718. Longest repeated subarray + lt.1143. Longest common subsequence
- Siemens PLM Teamcenter download, installation and use tutorial
- Notes - record a cannotfinddatasourceexception: dynamic datasource can not find primary datasource problem solving
- Yyds dry inventory how to locate browser page crash
- Legal mix of collations for operation 'Union' (bug record)
猜你喜欢

一元函数积分学_分部积分法

How does tiktok break zero?

PreScan快速入门到精通第十九讲之PreScan执行器配置、轨迹同步及非配多个轨迹

Distributed link logging minbox logging usage document
![[wp]ctfshow-web introductory information collection](/img/22/c2e5cca918800dda9df27272eb9871.png)
[wp]ctfshow-web introductory information collection

PMP每日一练 | 考试不迷路-7.25

919. Complete binary tree inserter

"Share" devaxpress asp Net v22.1 latest version system environment configuration requirements

Application of conductive slip ring in mechanical equipment

「分享」DevExpress ASP.NET v22.1最新版本系统环境配置要求
随机推荐
Gbase 8s UDR memory management_ 02_ mi_ dalloc
C language learning diary 3 - realloc function
国内常见php的CMS建站系统情况分析
sentinel简单限流和降级demo问题记录
导电滑环在机械设备方面的应用
what is qml in qt
binarySearch基础二分查找
Sentinel simple current limiting and degradation demo problem record
Day7:有序二叉树(二叉搜索树)
[artifact] screenshot + mapping tool snipaste
03-树1 树的同构
Is there a "fingerprint" in the structure of AAAI 2022 | Gan? Generating network structure from forged image traceability
Mobile phone touch picture slider rotation plug-in photoswipe.js
Authorized wireless communication standard
「分享」DevExpress ASP.NET v22.1最新版本系统环境配置要求
【神器】截图+贴图工具 Snipaste
CarSim仿真快速入门(十四)—CarSim-Simulink联合仿真
[good book recommendation] - authoritative guide to Ethernet (2nd Edition)
数字信息化(先枚举假设,再看是否满足条件)(1089 狼人杀-简单版)
Analysis of CMS station building system of common PHP in China