from seleniumwire import webdriver # Import from seleniumwire
Create a new instance of the Chrome driver
driver = webdriver.Chrome()
Go to the Google home page
driver.get('https://www.google.com')
Access requests via the requests
attribute
for request in driver.requests:
if request.response:
print(
request.url,
request.response.status_code,
request.response.headers['Content-Type']
)
在python3.10中运行出现错误报告:
ModuleNotFoundError: No module named 'cffi_backend'
thread '' panicked at 'Python API call failed', C:\Users\runneradmin.cargo\registry\src\index.crates.io-6f17d22bba15001f\pyo3-0.15.2\src\err\mod.rs:582:5
note: run with RUST_BACKTRACE=1
environment variable to display a backtrace
Traceback (most recent call last):
File "E:\文档\分区(已识别)(2)\多线程爬虫 - 副本\国家中小学智慧教育平台同步课堂.py", line 1, in
from seleniumwire import webdriver # Import from seleniumwire
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "F:\python\Lib\site-packages\seleniumwire\webdriver.py", line 28, in
from seleniumwire import backend, utils
File "F:\python\Lib\site-packages\seleniumwire\backend.py", line 4, in
from seleniumwire.server import MitmProxy
File "F:\python\Lib\site-packages\seleniumwire\server.py", line 5, in
from seleniumwire.handler import InterceptRequestHandler
File "F:\python\Lib\site-packages\seleniumwire\handler.py", line 5, in
from seleniumwire import har
File "F:\python\Lib\site-packages\seleniumwire\har.py", line 11, in
from seleniumwire.thirdparty.mitmproxy import connections
File "F:\python\Lib\site-packages\seleniumwire\thirdparty\mitmproxy\connections.py", line 9, in
from seleniumwire.thirdparty.mitmproxy import certs, exceptions, stateobject
File "F:\python\Lib\site-packages\seleniumwire\thirdparty\mitmproxy\certs.py", line 10, in
import OpenSSL
File "F:\python\Lib\site-packages\OpenSSL_init.py", line 8, in
from OpenSSL import SSL, crypto
File "F:\python\Lib\site-packages\OpenSSL\SSL.py", line 9, in
from OpenSSL._util import (
File "F:\python\Lib\site-packages\OpenSSL_util.py", line 6, in
from cryptography.hazmat.bindings.openssl.binding import Binding
File "F:\python\Lib\site-packages\cryptography\hazmat\bindings\openssl\binding.py", line 15, in
from cryptography.hazmat.bindings._rust import _openssl, openssl
pyo3_runtime.PanicException: Python API call failed