Sunday 15 February 2015

python - How to get all the requests from a page with open browser/webdriver -



python - How to get all the requests from a page with open browser/webdriver -

i'm trying requests open page. i'm using selenium python lib , didn't find way webdriver there ..

there anyway request header of things in page (css,img,audio,js)

i found selenium + browsermobproxy htttp requests have problem har file , open json , not seems reading requests google ..

my code :

from selenium import webdriver browsermobproxy import server import json server = server('path') server.start() proxy = server.create_proxy() url = "http://www.google.com" profile = webdriver.firefoxprofile('myprofile') profile.set_proxy(proxy.selenium_proxy()) driver = webdriver.firefox(firefox_profile=profile) proxy.new_har("google") driver.get(url) open("data.txt","w") outfile: json.dump(proxy.har, outfile) server.stop() driver.close()

edit :

i found problem .. when im using deafult firefoxprofile : profile = webdriver.firefoxprofile()

it work , when im come in path : c:/users/user/appdata/roaming/mozilla/firefox/profiles/7ysojjl9.default

im getting nil ..

python selenium request

No comments:

Post a Comment