How can I pass my ID and my password to a website in Python using Google App Engine?

前端 未结 2 1732
我在风中等你
我在风中等你 2021-01-24 01:41

Here is a piece of code that I use to fetch a web page HTML source (code) by its URL using Google App Engine:

from google.appengine.api import urlfetch
url = \"h         


        
相关标签:
2条回答
  • 2021-01-24 02:33

    As Alex said you can check for status code and see what type of autorization it wants, but you can not generalize it as some sites will not give any hint or only allow login thru a non standard form, in those cases you may have to automate the login process using forms, for that you can use library like twill (http://twill.idyll.org/) or code a specific form submit for each site.

    0 讨论(0)
  • 2021-01-24 02:39

    You can check for an HTTP status code of 401, "authorization required", and provide the kind of HTTP authorization (basic, digest, whatever) that the site is asking for -- see e.g. here for more details (there's not much that's GAE specific here -- it's a matter of learning HTTP details and obeying them!-).

    0 讨论(0)
提交回复
热议问题