PDA

View Full Version : n00b coding questions



mt5o5bd
02-05-2014, 02:28 AM
I'm running this piece of code in python.


url = 'randomloginpage'
body = 'randombody'
headers = {'Accept-Language': 'en-US,en;q=0.5', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'User-Agent' : 'Mozilla/5.0 (Windows NT; Win64; x64; rv:26.0) Gecko/20100101 Firefox/26.0 Waterfox/26.0', 'Accept-Encoding' : 'gzip, deflate'}
request = urllib2.Request(url, body, headers)
response = urllib2.urlopen(request)
html = response.read()
print html


I receive this response in my web debugger:

<script type="text/javascript">
window.location = 'index.php';
</script>
<div style="text-align:center; margin-top:20px;"><img src="../../images/layout/loading.gif" /> Logging in...</span>

The response I get in python.exe is like this weird combination of windings.

I run the code without the headers and I get the correct response in my web debugger.

What am I doing wrong? Dx

Josh
02-05-2014, 02:35 AM
Going to need more details then that. Just 1 idea, The site you are trying to log into might be checking the referer.

Note: Im not too familiar with python. But can most likely help

DarkByte
02-05-2014, 05:37 AM
[Only registered and activated users can see links]

I recomend using something like this , just because its nice and simple but it works. Also if u read my tutorials , I use the code from the above link so u can follow along easily :).


[Only registered and activated users can see links]
[Only registered and activated users can see links]