World's Best AI Learning Platform with profoundly Demanding Certification Programs
Designed by IITian's, only for AI Learners.
Download our e-book of Introduction To Python
4 (4,001 Ratings)
218 Learners
Shashank Shanu
5 months ago
import requests
USERNAME_ID = 'signup-user-name'
PASSWORD_ID = 'signup-user-password'
USERNAME = 'username'
PASSWORD = 'userpassword'
SIGNUP_URL = 'https://codepad.org/login'
def submit_form():
"""Submit a form"""
payload = {ID_USERNAME : USERNAME, ID_PASSWORD : PASSWORD,}
resp = requests.get(SIGNUP_URL)
print("Response to GET request: %s" %resp.content)
resp = requests.post(SIGNUP_URL, payload)
print("Headers from a POST request response: %s" %resp.headers)
#print "HTML Response: %s" %resp.read()
if __name__ == '__main__':
submit_form()
Response to GET request: <!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta HTTP-EQUIV="Pragma" CONTENT="no-cache">
<meta HTTP-EQUIV="Expires" CONTENT="-1">
<title>Login - codepad</title>
<link href="/main.css" media="screen" rel="stylesheet" type="text/css" />
<style type="text/css">
</style>
<script src='https://www.google.com/recaptcha/api.js'></script>
<script>
function onRecaptcha(token) {
document.getElementById("editor-form").submit();
}
</script>
</head>
<body >
.....................
.....................