Here is a bit of code, basically was stolen and improvised from about 3 or 4 chunks of code. Am I using requests properly?
Right now I figure I'll learn how to login into a webpage then begin doing other small tasks with that knowledge.
Right now I figure I'll learn how to login into a webpage then begin doing other small tasks with that knowledge.
Code
import requests
import sys
EMAIL = 'myusername'
PASSWORD = 'mypassword'
URL = 'http://bluelight.org/vb/login.php?do=login'
def main():
session = requests.session()
login_data = {
'loginemail': EMAIL,
'loginpswd': PASSWORD,
'submit': 'login',
}
try:
r = session.post(URL, data=login_data)
r = session.get('http://bluelight.org/vb/private.php?folderid=0')
print('Login Sucessful!')
except requests.exceptions.Timeout:
print("timeout!")
except requests.exceptions.TooManyRedirects:
print("To many redirects!")
except requests.exceptions.RequestException as e:
print e
sys.exit(1)
if __name__ == '__main__':
main()


![[Image: N43q1sy.png]](https://i.imgur.com/N43q1sy.png)