views:

201

answers:

2

Hello everybody!!!

I am trying to pass automatically, using Google App Engine, my password and ID to eBay, to this page:

https://signin.ebay.com/ws/eBayISAPI.dll?SignIn&UsingSSL=1&pUserId=&co_partnerId=2&siteid=0&ru=http%3A%2F%2Fcgi5.ebay.com%2Fws2%2FeBayISAPI.dll%3FSellItem%26hm%3Dum.rundkoi376%26%26hc%3D1%26guest%3D1&pageType=1144

(It is where I get redirected to from this URL: https://signin.ebay.com). Here is how the page looks like:alt text

Earlier I have asked some questions, and here one very nice supporter suggested that I use code from this link: http://chillorb.com/?p=195 If you have no time to go there, here is how that page looks like:

alt text

So, I pasted that code into my editor substituting the valid eBay URL, my ID and password. My ID there is seeyousoondanny and the password is happy1 (I created that account on eBay just for experimenting, so I am not afraid to give out my ID and password). Here is how the code looked in my editor:

alt text

But when I run this code I get only this:

alt text

What am I doing wrong here?

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Addition:

Here is the bottom of the error page (I think it will be seen clearer if you click on the link to this image):

alt text

+++++++++++++++++++++++++++++++++++++++++++++++++++

Addition:

I guess this code has no syntax mistakes:

from google.appengine.api import urlfetch
import base64

url = "https://signin.ebay.com/ws/eBayISAPI.dll?SignIn&UsingSSL=1&pUserId=&co_partnerId=2&siteid=0&ru=http%3A%2F%2Fcgi5.ebay.com%2Fws2%2FeBayISAPI.dll%3FSellItem%26hm%3Dum.rundkoi376%26%26hc%3D1%26guest%3D1&pageType=1144"
authString = 'Basic' + base64.encodestring('seeyousoondanny:happy1')
data = urlfetch.fetch(url, headers= {'AUTHORIZATION' : authString })
if data.status_code == 200:
   print "content-type: text/plain"
   print
   print data.status_code
+3  A: 

I'm not sure if this helps, but ebay has an API that would be simpler to use and incorporate. Check out http://developer.ebay.com/businessbenefits/aboutus/

aldrin
aldrin, it's like you have opened an altogether another world to me! I have never heard about this. I will still try to continue the way of Google App Engines, since I've already spent quite a lot of my time on it and others spent their time helping me here, but at least now I know that there is another way, which I'll be sure to explore too. Thanks again!
brilliant
Note that if you're scraping the pages of a big site with an API instead of using their API, they'll almost certainly eventually detect it and block you from accessing the site.
Wooble
@Wooble: "...they'll almost certainly eventually detect it and block you from accessing the site" - Thanks for telling me that. But I don't understand, why would they need to do that? What if I am just using my API to log-in to my account on their site and check some of pages there? For example, checking my eBay summary page on eBay. Would they still be not happy about that?
brilliant
@brilliant while registering at ebay you would have certainly agreed to their user agreement which prohibits any kind of scraping/automated access (see http://pages.ebay.com/help/policies/user-agreement.html). depending on your app purpose :) it's a grey area. however, as Wooble mentioned beware of your account being locked.
aldrin
@aldrin: "...at eBay <...> their user agreement which prohibits any kind of scraping/automated access..." - OUCH!!! Aldrin, you kind of poured a pail of cold water on me with this remark :( :). But there is something I don't quite understand here: Why I am allowed to browse their pages one by one manually, but when I just want to automate this process a bit. it is already a crime? I have already tried browsing their pages automatically from my computer using AHK and I wasn't blocked by them. Why not?
brilliant
Well I guess as long as it is under reasonable limits it should be okay. (say, a request frequency of every minute over 24 hours might look suspicious :) )
aldrin
+2  A: 

Looks like some of the quote-characters are the wrong kind -- reversed "smart quotes" rather than normal plain ordinary ASCII quote characters. Hard to say precisely from screenshots! The error screen you're showing (from GAE's SDK) shows the exact location of the error at the very bottom -- and you're showing it scrolled all the way to the very top, so it doesn't help.

In GAE like in any other use of Python quote is done via plain single and double quote characters: ' and " ; not via slanted, inverted, or "smart" quote characters, such as

`

(hard to clearly show the inverted single quote in SO except as a codeblock, since it's used to mark inline code;-) or , , , and so forth. So check your code carefully to make sure you're using the normal, plain kinds of quotes!

Alex Martelli
Aaaah! Thank you, Alex! Now I understand why my editor several times gave me a coding error message. I am going to try making these corrections now, and I have already added the screen shot of the bottom of the page.
brilliant
Alex, I think I have finally arrived at the right combination (please, see the code I just added in my question). When the last line is "print data.content" (without quotes) it displays the HTML code of that page, and when it's "print data.status_code" (without quotes) it shows me... 200 again! So, it seems that I have arrived at the same problem - I still get this 200, and my ID and Password don't seem to have been passed to the site.
brilliant
@brilliant, maybe ebay wants digest authentication, in which case you're definitely better off using the functionality urllib2 provides for the purpose, now that urllib2 is supported in GAE (urllib2 also supports basic auth, but that may be easier to fake by hand, sometimes;-).
Alex Martelli
@Alex Martelli: Thank you, Alex, again. It seems like I got so many different options now suggested here that I don't know even what to start with. Right now I am studying materials provided by Anurag here: http://stackoverflow.com/questions/1914275/googles-app-engine-python-how-to-get-parameters-from-a-log-in-pages . Where can I get this urllib2 that is supported by GAE?
brilliant
@brilliant, urllib2 is part of Python's standard library.
Alex Martelli
@Alex Martelli: Thank you, Alex. "...urllib2 is part of Python's standard library" - So, does that mean that if I have Python installed I already have urllib2?
brilliant
@brilliant, yes, if you have a complete and correct installation of Python, it does include urllib2.
Alex Martelli
@Alex Martelli: I see. Thank you.
brilliant