[Tutor] Urllib, mechanize, beautifulsoup, lxml do not compute (for me)!

Sander Sweers sander.sweers at gmail.com
Tue Jul 7 19:51:01 CEST 2009


2009/7/7 David Kim <davidkim05 at gmail.com>:
> opener = urllib2.build_opener(MyHTTPRedirectHandler, cookieprocessor)
> urllib2.install_opener(opener)
>
> response = urllib2.urlopen("http://www.dtcc.com/products/derivserv/data_table_i.php?id=table1")
> print response.read()
> ####
>
> I suspect I am not understanding something basic about how urllib2
> deals with this redirect issue since it seems everything I try gives
> me the same ToS page.

Indeed, you create the opener but then you do not use it. Try the
below and it should work.
  response = opener.open("http://www.dtcc.com/products/derivserv/data_table_i.php?id=table1")
  data = response.read()

Greets
Sander


More information about the Tutor mailing list