Tuesday, October 25, 2011

The python module : spynner

On official site we see the description of the spynner module :
Spynner is a stateful programmatic web browser module for Python with Javascript/AJAX support based upon the QtWebKit framework.
The module is esay to use. With few lines of codes you can use this module to parse ,view and use web pages.
from __future__ import division
from __future__ import unicode_literals
from __future__ import print_function
import re
import spynner
from BeautifulSoup import BeautifulSoup
import time
br = spynner.Browser()
br.create_webview()
br.show()
br.set_html_parser(BeautifulSoup)
br.load("http://www.linuxtoday.com/")
br.fill("input[name=username]", "name")
br.fill("input[name=passwd]", "pass")
#br.simulate_click("input[name=submit]",True)
#br.select("IBESNA~US")
#br.select('option[value="IBESNA~US"]')
#br.wait_page_load()
br.browse()

The result is show in the image bellow:
The source code is not complete. I make this simple example just to show us how to fill some editbox.
If you wantthen you can develop this script and make more useful.
I wait your answers with source code additions and new ways of using this python module.

4 comments:

jtrip said...

Hi there, I noticed you have experimented with spynner. I am currently working with it right now to do a little magic. One thing I have been wondering about is how to interact with a choose file dialog that the browser produced. Do you know what I mean. or have any idea where to look to?
Thanks!

Catalin Festila said...

I'm not using the spynner every day. Sorry

Nir Blinder said...

hi jtrip,
have you found any solution to your problem?
I am facing the same problem but I am working directly with qtwebkit api... thought maybe your solution can get me closer...

Jeremy Hall said...

you can execute javascript on the DOM to set the value of the upload file input element in the form.

Post a Comment