开发者

Is there some module for Python that works with Firefox?

Is there some module for Python that tells me when some page finish the loading, or something else o开发者_开发技巧n Firefox?


There's selenium

Code example test_google.py:

from selenium import selenium

sel = selenium("localhost", 4444, "*firefox", "http://www.google.com/webhp")
sel.start()

sel.open("http://www.google.com/webhp")
sel.type("q", "hello world")
sel.click("btnG")
sel.wait_for_page_to_load(5000)
assert "hello world - Google Search" == sel.get_title()
sel.stop()


You can use the moz-repl plugin. It will instantiate a command prompt on a local port and you can then script it using the cmd module. This will allow you to peek at the browser internals and get back the information you need.


you can alternatively try the gtkmozembed module. lets you run a firefox instance and load pages in there.

selenium might be best if you are just after load times, but if you want to do more interactions with the page, like execute javascript, or take screenshots even, gtkmozembed might be your man.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜