
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文件。
软件规格:
操作系统:Ubuntu16.04脚本语言: Python (2.7.8)自动化网页浏览器: Selenium (3.5.0) BrowserMob-Proxy: 0.8.0和2.1.4 (分别从pip和https://bmp.lightbody.net/安装)
我试着添加了shebang行,但没有帮助。不确定为什么我会收到这个错误。任何帮助都将不胜感激。谢谢。
发布于 2017-10-25 00:06:45
您是否尝试将#!/bin/sh添加到文件的开头?
https://stackoverflow.com/questions/45927286
复制相似问题