[twill] beautifulSoup via twill?

Mike Gleeson montara at sonic.net
Mon Jul 23 23:19:36 PDT 2007


Mike Gleeson wrote:
> noob question - I'm not understanding how mechanize/beautifulSoup are 
> utilized within Twill.  I'm wanting to implement automated monitoring 
> and parsing thereof and am unable to piece it together using python 
> interactively.  I'm trying to find a div via a css identifier and parse 
> out the inner html.  Should be straightforward but I don't see it.
>
> appreciate any help, thank you.
>
> - mike
>
>   
here's how far I can get, I'm hoping there's a preferred way to utilize 
mechanize and beautifulsoup:

from twill import *
from mechanize import _beautifulsoup
soup = _beautifulsoup.BeautifulSoup
b = get_browser()
b.go('http://somedomain.com')
x = soup(b.get_html()) 
y = x.fetch('div')
// and parse from there

comments, suggestions?

thanks,

mike




More information about the twill mailing list