We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
如下是 test1.py,它先打开bilibili,然后手动登录(使用手机扫码或者输入账号密码),手动登录成功后获取到cookies,输出cookies,然后清除cookies,再设置cookies,这个是能登录上的。
test1.py:
import time # 导入 ChromiumOptions from DrissionPage import Chromium, ChromiumOptions co = ChromiumOptions().auto_port() # 使用该配置对象创建页面 browser = Chromium(co) tab = browser.latest_tab # 访问网页 tab.get('https://www.bilibili.com/') # 手动登录 time.sleep(50) # 输出cookies all_cookies = tab.cookies() print(all_cookies) # 先清除cookies time.sleep(2) tab.set.cookies.clear() #刷新 time.sleep(2) tab.refresh() # 然后设置cookies time.sleep(10) tab.set.cookies(all_cookies) #刷新 time.sleep(2) tab.refresh()
输出的all_cookies格式为:
[{'name': 'xxx', 'value': 'xxx', 'domain': '.bilibili.com'}, {'name': 'xxx', 'value': 'xxx', 'domain': '.bilibili.com'}, ……]
然后我把输出的all_cookies,直接复制,严格检查后没有错,贴到 test2.py 里,但是发现登录不上。 请问各位大佬为什么,以及怎么解决?
test2.py:
import time # 导入 ChromiumOptions from DrissionPage import Chromium, ChromiumOptions co = ChromiumOptions().auto_port() # 使用该配置对象创建页面 browser = Chromium(co) tab = browser.latest_tab # 访问网页 tab.get('https://www.bilibili.com/') # 先清除cookies time.sleep(2) tab.set.cookies.clear() #刷新 time.sleep(2) tab.refresh() # 然后设置cookies time.sleep(10) all_cookies= [{'name': 'xxx', 'value': 'xxx', 'domain': '.bilibili.com'}, {'name': 'xxx', 'value': 'xxx', 'domain': '.bilibili.com'}, ……] tab.set.cookies(all_cookies) #刷新 time.sleep(2) tab.refresh()
The text was updated successfully, but these errors were encountered:
No branches or pull requests
如下是 test1.py,它先打开bilibili,然后手动登录(使用手机扫码或者输入账号密码),手动登录成功后获取到cookies,输出cookies,然后清除cookies,再设置cookies,这个是能登录上的。
test1.py:
输出的all_cookies格式为:
然后我把输出的all_cookies,直接复制,严格检查后没有错,贴到 test2.py 里,但是发现登录不上。
请问各位大佬为什么,以及怎么解决?
test2.py:
The text was updated successfully, but these errors were encountered: