[Tutor] getting results from encoded data i sent to website
Benjamin Fishbein
bfishbein79 at gmail.com
Fri Jul 27 23:47:41 CEST 2012
I'm trying to learn encoding, and I've had a bit of success. I managed to input something to the text box on Python's home page and I got the result I expected. But I can't figure out why this program I wrote isn't working; I think I did everything right.
I'm inputting the isbn of Cat in the Hat and trying to get the prices for it on half.com, the Ebay site for books.
Here's my code:
### This program tries to check the prices for "The Cat in the Hat" on http://half.com
#import modules
import urllib
import urllib2
#make variables
action="http://sell.half.ebay.com/ws/eBayISAPI.dll?HalfInstantSaleHub&action=search"
name="isbnupcnumbers"
cat_in_hat_isbn="039480001X"
#get stuff encoded
data={name:cat_in_hat_isbn}
encoded_data=urllib.urlencode(data)
#send encoded stuff to website
content=urllib2.urlopen(action, encoded_data)
#look at results
print content.readlines()
#next I'll parse out the data I want; that I already know how to do.
The program seems to be working until "content" is printed. Then it's a lot of strange mumbo-jumbo, quite different from the results I get if I put in the isbn manually.
Do you know where I went wrong?
Thanks,
Ben
More information about the Tutor
mailing list