urllib and parsing
Tim Roberts
timr at probo.com
Thu Oct 6 03:05:01 EDT 2011
luca72 <lucaberto at libero.it> wrote:
>
>Hello i have a simple question:
>up to now if i have to parse a page i do as follow:
>...
>Now i have the site that is open by an html file like this:
>...
>how can i open it with urllib, please note i don't have to parse this
>file, but i have to parse the site where he point.
Well, you can use htmllib to parse the HTML, look for the "form" tag, and
extract the "action" verb. Or, if you really just want this one site, you
can use urllib2 to provide POST parameters:
import urllib
import urllib2
url = 'http://lalal.hhdik/'
values = {'password' : 'password',
'Entra' : 'Entra' }
data = urllib.urlencode(values)
req = urllib2.Request(url, data)
response = urllib2.urlopen(req)
the_page = response.read()
--
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.
More information about the Python-list
mailing list