简体   繁体   English

如何使用 python 请求获取网络选项卡?

[英]How can i get the network tab with python requests?

headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:80.0) Gecko/20100101 Firefox/80.0'}
proxies = {
    'http': 'http://' + "185.169.198.98:3128",
    'https': 'http://' + "185.169.198.98:3128",
}
r = requests.get(url,verify=True,headers=headers,proxies=proxies)

i want to get the network data like in the browser but with requests我想像在浏览器中一样获取网络数据但有请求

Image here.图片在这里。

Not sure if it will be possible to capture this with requests , but you can try to do this with selenium wire :不确定是否可以通过requests捕获此内容,但您可以尝试使用selenium wire执行此操作:

from seleniumwire import webdriver  # Import from seleniumwire  

# Create a new instance of the Firefox driver  
driver = webdriver.Firefox()  

# Go to the Google home page  
driver.get('https://www.google.com')  

# Access and print 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'])  

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM