MSIE6 Python Question
Ralph A. Gable
r.gable at mchsi.com
Sat May 29 07:02:22 EDT 2004
I tried this bur it did not work. From that I assume they are
using cookies. Since I am not handling them (using this method),
the figure that out and fill in the page with dashes where I get
data when processing the HTML through MSIE.
Thanks for your suggestion.
milas_gi at hotmail.com (tutu) wrote in message news:<5d1dd116.0405270818.46f43d5b at posting.google.com>...
> > > I'm not sure why you need to go through IE, but maybe this will get you into
> > > the right direction:
> > >
> > > >>> import urllib
> > > >>> f = urllib.urlopen('http://www.python.org')
>
> >
> >
> > Sorry. I forgot to mention that I have tried that. The data I want is
> > being stripped out when I access the URL via urllib.
>
>
> Try something like this:
> It may be the site does not like urllib agent so try to pretend you are using IE.
> class URLHandler(urllib2.HTTPRedirectHandler, urllib2.HTTPDefaultErrorHandler):
> pass
> agent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)"
> request = urllib2.Request(url)
> request.add_header("User-Agent", agent)
> opener = urllib2.build_opener(URLHandler())
> opener.addheaders = [] # RMK - must clear so we only send our custom User-Agent
> htm = opener.open(request)
> opener.close()
> htm.read()
>
> Good Look
More information about the Python-list
mailing list