Modification of a urllib2 object ?

vincehofmeister at gmail.com vincehofmeister at gmail.com
Fri Oct 10 14:32:25 EDT 2008


I have several ways to the following problem.

This is what I have:

...
import ClientForm
import BeautifulSoup from BeautifulSoup


request = urllib2.Request('http://form.com/)

self.first_object = urllib2.open(request)

soup = BeautifulSoup(self.first_object)

forms = ClienForm.ParseResponse(self.first_object)


Now, when I do this, forms returns an index errror because no forms
are returned, but the BeautifulSoup registers fine.

Now, when I switch the order to this:


import ClientForm
import BeautifulSoup from BeautifulSoup


request = urllib2.Request('http://form.com/)

self.first_object = urllib2.open(request)

forms = ClienForm.ParseResponse(self.first_object)

soup = BeautifulSoup(self.first_object)

Now, the form is returned correctly, but the BeautifulSoup objects
returns empty.

So what I can draw from this is both methods erase the properties of
the object, so i tried importing the copy module and uses
copy.deepcopy(self.first_object)...

this didn't work either.

Does anyone have any idea on this or what I should do so the object
does not get erased.

Thanks in advance for any advice in advance.






More information about the Python-list mailing list