How to login with python and save cookie, then use that info to view page for member only -


I am quite new in Python and am trying to write a script to login to the page.

I have tried many endeavors, but it fails to login and I do not know why after logging in on the page, I want to get a return of

I has tried to try an example by reading examples from other examples from here.

  import urllib, urllib2, cookielib Username = 'myusername' password = 'mypassword' cj = cookielib.CookieJar () opener = urllib2.build_opener (urllib2.HTTPCookieProcessor (CG)) login_data = urllib. urlencode ({ 'login: username, password: password}) Opener.open (' http://www.ryushare.com/login.python ', login_data) resp = opener.open (' http: // ryushare.com/file-manager.python ') print resp.read ()   

I examine the source code of the login page, I said that users value name and password "login and password "That's why I change it. I try some other examples which can be found here like a Google News feed, it is not able to login:>

In the source of the page, we have the following HTML:

  & lt; Form method = "POST" action = "http://ryushare.com/" name = "FL" & gt;   

You should be open () 'Action Page', such as

  opener.open ('http://ryushare.com) /', login_data ) # you can now interact with the site   

:

Submit button

& lt; input type

a submit button is used to access the server to send the form data. attribute data is sent to the designated page as a form of action. define file action attribution Generally received input The few with:

  & lt; form name = "input" action = "html_form_action.asp" method = "" Username: & lt; input type = "text" name = " User "/> receive  & Lt; / Form & gt;   

The HTML code given above looks like in a browser:

Username: (entry box)

If you have something in the text field Type the letter up, and click the "Submit" button, the browser will send your input to the page named "html_form_action.asp". The page will show you the input received.

Edit: Other Form Data

As observed in the comments, OP still had trouble after deciding it. The answer is that there are often hidden form tags for submitted buttons. Include your tags of these tags along with your request as well as your username and password.

Comments