Home > other >  Why browsermob - proxy request, will get the request of less than chrome?
Why browsermob - proxy request, will get the request of less than chrome?

Time:09-16

Chrome requests, 53

Browsermob - proxy requests, 48


My code
 
_ # _ * coding: utf-8 _ * _
The from the selenium import webdriver
The from the selenium. Webdriver. Chrome. The options import options
The from browsermobproxy import Server
The import json
From the time the import sleep

Try:
# start the broker
Server=server (r '/Users/renguanyu/app/browsermob - proxy/2.1.4/bin/browsermob - proxy')
Server. The start ()
The proxy=server. Create_proxy ()

# launch a browser
Chrome_options=Options ()
Chrome_options. Add_argument (' - ignore - certificate - errors')
Chrome_options. Add_argument (' -- proxy server -={0} '. The format (proxy. Proxy))
# chrome_options. Add_argument (' - headless ') # headless mode
Browser=webdriver. Chrome (options=chrome_options)
The implicitly_wait (60)

# surveillance results
Url='https://www.baidu.com/'
Proxy. New_har (options={
'captureContent: True,
'captureHeaders: True
})
The get (url)

# print network
Result=proxy. Har
The log=result (" log ")
Entries=log (" entries ")

List=[]
For entrie entries in:
Request=entrie (" request ")
Request_url=request (" url ")
The response=entrie [" response "]
Status=response (" status ")

Dict={
"Url" : request_url,
"Status" : the status
}
List. Append (dict)

# sleep (30)
Print (" request_list ", a list)
Print (" request_list_length, "len (list))

Finally:
Print (" complete, ready to shut down the program ")
# sleep (3)
# close proxy and browser
Proxy. The close ()
Print (" closed agent ")
# the close ()
The quit ()
Print (" close the browser ")
  • Related