1

I was wondering what makes me unable to log in to a website in python using post. I've tried so many examples taken from stackoverflow and they are very easy to use. The same code works for me with other sites but not for this one. The URL is mentioned in the code below:

import cookielib
import urllib
import urllib2

url = 'http://www.mawaly.com/login?href='
data='form_action=true&email=someone%40hotmail.com&passw=pwd&remember_me=1&submit=%D8%AF%D8%AE%D9%88%D9%84'

opener = urllib2.build_opener(
    urllib2.HTTPRedirectHandler(),
    urllib2.HTTPHandler(debuglevel=0),
    urllib2.HTTPSHandler(debuglevel=0),
    urllib2.HTTPCookieProcessor(cookies))

response = opener.open(url, data)
page = response.read()
headers = response.info()
print headers
print page

The page contents are either blank or 20 characters of some strange encoding. I tried navigating to the homepage first to get the cookies but nothing changed. I got the data to submit from Firefox using Tamper Data and used them in this form because the submit value is in Arabic "دخول" and urlencode doesn't match with the same encoded by Firefox but though I tried them both...One more point is that the connection's value in the response header is closed even if I set it to Keep-Alive in request I would appreciate any help..Thanks in advance

Ammar Mohammad
  • 126
  • 1
  • 8

0 Answers0