Benjamin Fishbein | 27 Jul 2012 23:47
Picon

getting results from encoded data i sent to website

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
(Continue reading)

Prasad, Ramit | 28 Jul 2012 00:33
Picon
Favicon

Re: getting results from encoded data i sent to website

> 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=s
> earch"
> 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()
(Continue reading)


Gmane