-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathselenium_wire.py
More file actions
35 lines (24 loc) · 1.1 KB
/
Copy pathselenium_wire.py
File metadata and controls
35 lines (24 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# Extends Selenium to give you the ability to inspect requests made by the browser.
# PyPi: https://pypi.org/project/selenium-wire/
# Github: https://github.com/wkeeling/selenium-wire
# pip install selenium-wire
# example
from seleniumwire import webdriver
# Options
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--headless')
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--ignore-certificate-errors-spki-list')
chrome_options.add_argument('--ignore-ssl-errors')
options = {'proxy': {'http': 'http://myusername:password@myproxyserver.com:123456',
'https': 'http://myusername:password@myproxyserver.com:123456',
'no_proxy': 'localhost,127.0.0.1'}}
driver== webdriver.Chrome('chromedriver', options=chrome_options, seleniumwire_options=options)
driver = webdriver.Firefox()
driver.get('https://www.google.com')
for request in driver.requests:
if request.response:
print(request.url,
request.response.status_code,
request.response.headers['Content-Type']
)