python - 如何使用指定的浏览器获取 url?
问题描述
这是我的代码:
import requests
from bs4 import BeautifulSoup
Url = "https://gmail.com"
R = requests.get(Url)
Soup = BeautifulSoup(R.text,"lxml")
print(Soup)
但我需要我的 cookie、登录数据和其他东西,它们存储在谷歌浏览器中,所以我想通过谷歌浏览器获取 url。
Google Chrome 的路径:“C:\Program Files\Google\Chrome\Application\chrome.exe”
那可能吗?谢谢...
解决方案
问题是你必须使用 selenium,下载 chrome webdriver `options = webdriver.ChromeOptions() options.add_argument('--start-maximized') options.add_argument('--disable-extensions')
driver_path='C:\Users\your_user_here\Downloads\chromedriver.exe'
driver = webdriver.Chrome(driver_path, chrome_options=options)`
推荐阅读
- android-studio-3.0 - 不幸的是,应用程序已停止但 colud 找不到 logcat
- python - 想要从 url 访问特定的字典值并在 python 中获取 key 0 错误
- java - 如何让 Java TCP 服务器和客户端应用程序循环,直到发出一定数量的请求
- python-3.x - 如何将python中的a / p(am / pm)时间值转换为24小时格式
- c - Lua 使用带有 C API 的可选表值
- javascript - 物体移动到画布外时的奇怪行为 t-rex
- python - Stackplot pandas groupby
- javascript - 使用 ajax 显示模式 - Laravel
- ios - 如何构建包含段落的可下载内容包?
- cakephp - cakephp 无法在数据库中保存表单控制字段