如何使用python请求获取网络选项卡?
我想像在浏览器中一样获取网络数据,但需要请求如何使用python请求获取网络选项卡?,python,networking,python-requests,Python,Networking,Python Requests,我想像在浏览器中一样获取网络数据,但需要请求 不确定是否可以通过请求捕获此信息,但您可以尝试使用selenium wire: 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'
不确定是否可以通过
请求捕获此信息,但您可以尝试使用selenium wire
:
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)
你可以得到所有的数据,你如何得到它取决于你想要什么。您可以使用r.headers
获取标题。通过requests
i需要媒体链接,您实际上想要从网络选项卡中获得什么。(参见img)但每当im发送请求时,链接都会发生变化
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'])