That same code works in a controller -- it was merely being demonstrated in
a shell. Instead of urllib.urlopen, you can now use fetch (which also works
on GAE):
from gluon.tools import fetch
page = TAG(fetch('http://www.web2py.com'))
page.elements('div') # gives you a list of all DIV elements in the page (as
web2py DIV helper objects)
Actually, at the moment, the above will generate an error because
apparently there is an unbalanced <a> tag somewhere on the web2py.com page.
Anthony
On Friday, May 3, 2013 3:15:55 AM UTC-4, Timmie wrote:
>
> Hello,
> is there an example how to use this:
>
> scraping utils
> https://groups.google.com/forum/?fromgroups=#!topic/web2py/skcc2ql3zOs
>
> in a controller?
>
> Especially the first lines (fetching the page and getting it into an
> element) is what I am looking for.
>
>
> The above example is made for the shell access.
>
> Thanks and kind regards,
> Timmie
>
>
>
--
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.