I am trying to log into website with my username and password but I just cannot seem to get it working. Right now I am testing by using the website. If I am able to log in, I should be able to find the bit that says The SnowBomb Platinum Membership. If I am not able to login, I should find the lost_password text in the source code.
This is what I have:
info = {
'USERNAME' : 'username',
'PASSWORD' : 'password',
#'submit' : 'login' don't know if i need this
}
def main():
r = requests.post('http://www.snowbomb.com/my-account-2', data = info) #logged in
request = requests.get('http://www.snowbomb.com/my-account-2')
if 'lost_password' in request.content:
print 'Was not able to log in'
print 'lost_password' in request.content
else:
if 'The SnowBomb Platinum Membership' in request.content:
print 'Logged in'
print 'The SnowBomb Platinum Membership' in request.content #--> when it works
if __name__ == '__main__':
main()
Here is the form in the source code when asking user to log in:
<form method="post" class="login">
<p class="form-row form-row-first">
<label for="username">Username <span class="required">*</span></label>
<input type="text" class="input-text" name="username" id="username" />
</p>
<p class="form-row form-row-last">
<label for="password">Password <span class="required">*</span></label>
<input class="input-text" type="password" name="password" id="password" />
</p>
<div class="clear"></div>
<p class="form-row">
<input type="hidden" id="_n" name="_n" value="a046c51363" /><input type="hidden" name="_wp_http_referer" value="/my-account-2/" /><input type="hidden" name="redirect" value="http://www.snowbomb.com/my-account"/>
<input type="submit" class="button" name="login" value="Login" />
<a class="lost_password" href="http://www.snowbomb.com/wp-login.php?action=lostpassword&redirect_to=http://www.snowbomb.com">Lost Password?</a>
</p>
</form>
r = requests.post('http://www.snowbomb.com/my-account-2', data = info) request = requests.get('http://www.snowbomb.com/my-account-2'), use this:request = requests.get('http://www.snowbomb.com/my-account-2', auth = info)TypeError: 'dict' object is not callableif 'The SnowBome Platinum Membership' in request.content: is that a typo you made just in the question, or are you checking for the wrong string in your code?infois a dictionary; defineinfoas a tuple, like this:info = ("username", "password"), then use the commands that I've provided before.