Skip to content

Instantly share code, notes, and snippets.

@Vostbur
Created March 30, 2013 18:37
Show Gist options
  • Save Vostbur/5277845 to your computer and use it in GitHub Desktop.
Save Vostbur/5277845 to your computer and use it in GitHub Desktop.
POST request for login to http://podfm.ru
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import urllib
import urllib2
import cookielib
LOGIN, PASSWORD = 'username', 'password'
cookie = cookielib.CookieJar()
urllib2.install_opener(urllib2.build_opener(urllib2.HTTPCookieProcessor(cookie)))
params = urllib.urlencode({
'a_todo': 'login_check',
'todo': 'login',
'login': LOGIN,
'password': PASSWORD,
'remember': 'on',
})
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.172 Safari/537.22'}
conn = urllib2.Request('http://podfm.ru/login/', params, headers)
data = urllib2.urlopen(conn)
with open('result_podfm.html', 'w') as f:
f.write(data.read())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment