你好,我想捕捉所有重定向,當他們發生。 可以先說到example.com,然後重定向到example1.com,之後example3.comwatir webdriver browsermob/proxy har文件幾乎爲空
我使用watir webdriver和browsermob/proxy。 我試過google.com,那不重定向,但har文件應該遠遠多於我得到的。
票數是代碼:
server = BrowserMob::Proxy::Server.new("/home/da/Downloads/browsermob-proxy-2.0.0/bin/browsermob-proxy") #=> #<BrowserMob::Proxy::Server:0x000001022c6ea8 ...>
server.start
@@proxy = server.create_proxy(9090)
puts @@proxy.inspect
profile = Selenium::WebDriver::Firefox::Profile.new
puts "going on #{dv}"
profile['general.useragent.override'] = dv['useragent']
#'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:27.0) Gecko/20100101 Firefox/27.0'#device['useragent']
puts dv['useragent']
profile.proxy = Selenium::WebDriver::Proxy.new :http => 'localhost:9090', :ssl => 'localhost:9090'#9091
time = Time.now.to_i #Time.now.getutc
puts APP_ROOT
@@proxy.new_har time
@@b = Watir::Browser.new :firefox, :profile => profile
@@har = @@proxy.har #=> #<HAR::Archive:0x-27066c42d7e75fa6>
#har.entries.first.request.url
#har.entries.first.request.url #=> "http://google.com"
@@b.goto "google.com"
puts @@har.inspect
@@har.save_to "#{APP_ROOT}/har/google.har"
exit
,這就是我得到
{"log":{"version":"1.2","creator":{"name":"BrowserMob Proxy","version":"2.0","comment":""},"browser":{"name":"IE","version":"11.0","comment":""},"pages":[{"id":"1479767515","startedDateTime":"2016-11-21T23:31:56.561+01:00","title":"","pageTimings":{"comment":""},"comment":""}],"entries":[{"pageref":"1479767515","startedDateTime":"2016-11-21T23:32:02.146+01:00","request":{"method":"GET","url":"https://tiles.services.mozilla.com/v3/links/fetch/en-US/release","httpVersion":"HTTP/1.1","cookies":[],"headers":[],"queryString":[],"headersSize":370,"bodySize":0,"comment":""},"response":{"status":303,"statusText":"SEE OTHER","httpVersion":"HTTP/1.1","cookies":[],"headers":[],"content":{"size":0,"mimeType":"text/html; charset=utf-8","comment":""},"redirectURL":"","headersSize":266,"bodySize":0,"comment":""},"cache":{},"timings":{"blocked":101,"dns":266,"connect":238,"send":1,"wait":205,"receive":832,"ssl":0,"comment":""},"serverIPAddress":"52.32.150.180","comment":"","time":1643},{"pageref":"1479767515","startedDateTime":"2016-11-21T23:32:02.791+01:00","request":{"method":"POST","url":"https://location.services.mozilla.com/v1/country?key=7e40f68c-7938-4c5d-9f95-e61647c213eb","httpVersion":"HTTP/1.1","cookies":[],"headers":[],"queryString":[{"name":"key","value":"7e40f68c-7938-4c5d-9f95-e61647c213eb"}],"headersSize":419,"bodySize":2,"comment":""},"response":{"status":200,"statusText":"OK","httpVersion":"HTTP/1.1","cookies":[],"headers":[],"content":{"size":49,"mimeType":"application/json; charset=UTF-8","comment":""},"redirectURL":"","headersSize":227,"bodySize":49,"comment":""},"cache":{},"timings":{"blocked":0,"dns":9,"connect":45,"send":17,"wait":60,"receive":511,"ssl":0,"comment":""},"serverIPAddress":"52.19.86.22","comment":"","time":642}],"comment":""}}
我試圖像上面example1.com提到exmple2.com和Har文件是不是給多重定向:(
這裏有一些測試中,我預製:
確定這裏的一些測試結果: 火狐2.0.0 49不會在所有 火狐2.1.2 49在所有的工作 火狐2.1.2 48不工作的時候
火狐2.1.2 47個作品不工作,但喀拉是小 火狐2.0.0 47幅哈日作品文件較大 火狐2.1.0 47哈日工作中間是大 火狐2.1.1 47部作品,這是最大的
然後我用Firefox 46還測試並得到了相同的結果。 ...
我記得幾年前我也得到了相同的代碼重定向,現在可以得到它:(