Home | Trees | Indices | Help |
|
---|
|
Stateful programmatic web browser class based upon QtWebKit.
>>> browser = Browser() >>> browser.load("http://www.wordreference.com") >>> browser.runjs("console.log('I can run Javascript!')") >>> browser.runjs("_jQuery('div').css('border', 'solid red')") # and jQuery! >>> browser.select("#esen") >>> browser.fill("input[name=enit]", "hola") >>> browser.click("input[name=b]", wait_load=True) >>> print browser.url, len(browser.html) >>> browser.close()
Instance Methods | |||
|
|||
Basic interaction with browser | |||
---|---|---|---|
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
Webview | |||
|
|||
|
|||
|
|||
|
|||
|
|||
Form manipulation | |||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
Javascript | |||
|
|||
|
|||
|
|||
Cookies | |||
|
|||
|
|||
Download files | |||
|
|||
HTML and tag soup parsing | |||
|
|||
|
|||
HTTP Authentication | |||
|
|||
Miscellaneous | |||
|
|||
|
|||
|
Instance Variables | |
ignore_ssl_errors = True If True, ignore SSL certificate errors. |
|
user_agent = None User agent for requests (see QWebPage::userAgentForUrl for details) |
|
jslib =
Library name for jQuery library injected by default to pages. |
|
download_directory =
Directory where downloaded files will be stored. |
|
debug_stream = sys.stderr File-like stream where debug output will be written. |
|
debug_level = 0 Debug verbose level (ERROR, WARNING, INFO or DEBUG). |
|
event_looptime = 0.01 Event loop dispatcher loop delay (seconds). |
|
application PyQt4.QtGui.Qapplication object. |
|
webpage PyQt4.QtWebKit.QWebPage object. |
|
webframe PyQt4.QtWebKit.QWebFrame main webframe object. |
|
webview PyQt4.QtWebKit.QWebView object. |
|
manager PyQt4.QtNetwork.QTNetworkAccessManager object. |
|
cookiesjar PyQt4.QtNetwork.QNetworkCookieJar object. |
Properties | |
url Current URL. |
|
html Rendered HTML in current page. |
|
soup HTML soup (see set_html_parser). |
Method Details |
Init a Browser instance.
|
Click any clickable element in page. @param selector: jQuery selector. @param wait_load: If True, it will wait until a new page is loaded. @param timeout: Seconds to wait for the page to load before raising an exception. @param wait_requests: How many requests to wait before returning. Useful for AJAX requests. By default this method will not wait for a page to load. If you are clicking a link or submit button, you must call this method with C{wait_load=True} or, alternatively, call L{wait_load} afterwards. However, the recommended way it to use L{click_link}. When a non-HTML file is clicked this method will download it. The file is automatically saved keeping the original structure (as wget --recursive does). For example, a file with URL I{http://server.org/dir1/dir2/file.ext} will be saved to L{download_directory}/I{server.org/dir1/dir2/file.ext}. |
Wait until the page is loaded.
|
Wait some time.
|
Inject Javascript code into the current context of page.
Note: You can change the _jQuery alias (see jslib). |
Set function callback for Javascript confirm pop-ups. By default Javascript confirmations are not answered. If the webpage you are working pops Javascript confirmations, be sure to set a callback for them. Calback signature:
The callback should return a boolean (True meaning 'yes', False meaning 'no') |
Set function callback for Javascript prompt. By default Javascript prompts are not answered. If the webpage you are working pops Javascript prompts, be sure to set a callback for them. Callback signature:
The callback should return a string with the answer or None to cancel the prompt. |
Download a given URL using current cookies.
Note: If url is a path, the current base URL will be pre-appended. |
Set HTML parser used to generate the HTML soup.
|
Set HTTP authentication request callback. The callback must have this signature:
The callback should return a pair of string containing (user, password) or None if you don't want to answer. |
Take an image snapshot of the current frame.
|
Set function callback to filter URL. By default all requested elements of a page are loaded. That includes stylesheets, images and many other elements that you may not need at all. Use this method to define the callback that will be called every time a new request is made. The callback must have this signature:
It should return |
Property Details |
urlCurrent URL.
|
htmlRendered HTML in current page.
|
soupHTML soup (see set_html_parser).
|
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Thu Mar 24 17:20:02 2011 | http://epydoc.sourceforge.net |