from browsermobproxy import Server
server = Server("path/to/browsermob-proxy")
server.start()
proxy = server.create_proxy()
from selenium import webdriver
profile = webdriver.FirefoxProfile()
profile.set_proxy(proxy.selenium_proxy())
driver = webdriver.Firefox(firefox_profile=profile)
proxy.new_har("google")
driver.get("http://www.google.co.uk")
proxy.har # returns a HAR JSON blob
server.stop()
driver.quit()
从https://browsermob-proxy-py.readthedocs.io/en/stable/index.html获取上述代码
我尝试使用broswermobproxy和selenium导出HAR文件。在
软件规格:
操作系统:Ubuntu 16.04 脚本语言:Python(2.7.8) 自动Web浏览器:Selenium(3.5.0) BrowserMob代理:0.8.0和2.1.4(分别从pip和https://bmp.lightbody.net/安装)
我试着添加shebang行,但没用。不知道我为什么会出错。任何帮助都将不胜感激。谢谢。在
你试过加上#!/bin/sh到文件的开头?在
相关问题 更多 >
编程相关推荐