[Tutor] getting results from encoded data i sent to website

Prasad, Ramit ramit.prasad at jpmorgan.com
Sat Jul 28 00:33:54 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=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()
> 
> #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.

What do you mean by "mumbo-jumbo"? Can you provide a small sample?
How do you "put in the isbn manually"?

> Do you know where I went wrong?

I ran the program and printed the first 5-10 lines. It seemed like 
valid HTML code as I skimmed it. What output did you expect?


Ramit
This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.  


More information about the Tutor mailing list