from seleniumwire import webdriver 在抓取http://链接的时候会自动转https://这个怎么解决?
from selenium import webdriver 这个抓取就正常不会自动转。
另外我抓取的时候用的代理IP,请问怎么解决
from seleniumwire import webdriver 在抓取http://链接的时候会自动转https://这个怎么解决
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-
27条回答 默认 最新
阿里嘎多学长 2024-09-01 23:45关注获得0.30元问题酬金 AIGC生成:
阿里嘎多学长的回答
你好!我看到你遇到了一个问题,使用
seleniumwire库抓取 HTTP 链接时,自动转换为 HTTPS 链接。这是一个常见的问题。解决这个问题有多种方法。下面是一些可能有用的解决方案:
- 使用
seleniumwire库的options参数来设置是否自动转换协议。例如:
from seleniumwire import webdriver options = webdriver.ChromeOptions() options.add_argument('--ignore-ssl-errors') options.add_argument('--ignore-certificate-errors') driver = webdriver.Chrome(options=options)这将忽略 SSL 错误和证书错误,从而避免自动转换协议。
- 使用
requests库来发送 HTTP 请求,而不是使用seleniumwire库。例如:
import requests response = requests.get('http://example.com')这将发送一个 HTTP GET 请求,而不是使用
seleniumwire库来抓取页面。- 使用
seleniumwire库的execute_cdp_cmd方法来执行 Chrome DevTools Protocol 命令。例如:
from seleniumwire import webdriver driver = webdriver.Chrome() driver.execute_cdp_cmd('Network.setIgnoreSSLErrors', {'ignoreSSL': True})这将设置 Chrome 的网络设置,忽略 SSL 错误。
这些解决方案都可以解决你遇到的问题。但是,如果你需要使用
seleniumwire库来抓取页面,那么使用options参数或execute_cdp_cmd方法可能是最好的选择。希望这些解决方案能够帮助你解决问题。如果你需要更多帮助,请随时问我!
评论 打赏 举报解决 1无用- 使用