Выкладываю весь код, логин & пароль рабочие, надеюсь на порядочность юзеров и ни кто акк не уведёт :D
#-*-encoding:UTF-8-*-
import re, urllib2, urllib, cookielib
myya_authorization_url = 'https://passport.yandex.ru/passport?mode=auth'
myya_authorization_login = 'pythonerblog'
myya_authorization_pass = '111111'
myya_posting_url = 'http://pythonerblog.ya.ru/post_do_save.xml'
title = 'тайтл как бэ'
text = 'текст псто!'
def authorization():
global page
idkey = urllib2.urlopen(myya_authorization_url).read()
idkey = re.findall('\<input type\=\"hidden\" name\=\"idkey\" value\=\"(.*)\" \/\> \<input type\=\"hidden\" name\=\"timestamp\" value\=\"\" \/\>', idkey)
data = urllib.urlencode({
'login': myya_authorization_login,
'passwd': myya_authorization_pass,
'timestamp': '',
'twoweeks': 'yes',
'In': 'Войти',
})
headers = {"User-Agent" : "Opera/9.64 (Windows NT 5.1; U; en) Presto/2.1.1",
"Accept" : "text/html, application/xml;q=0.9, application/xhtml+xml, image/png, image/jpeg, image/gif, image/x-xbitmap, */*;q=0.1",
"Accept-Language" : "ru,uk-UA;q=0.9,uk;q=0.8,en;q=0.7",
"Accept-Charset" : "iso-8859-1, utf-8, utf-16, *;q=0.1",
"Accept-Encoding" : "identity, *;q=0",
"Connection" : "Keep-Alive",}
cookies = cookielib.CookieJar()
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookies))
urllib2.install_opener(opener)
req = urllib2.Request(myya_authorization_url, data, headers)
page = urllib2.urlopen(req).read()
return cookies
def posting(cookies):
global page2
data = urllib.urlencode({
'access_type': 'public',
'replies': '1',
'title': title,
'body': text,
'tags': '',
'tag': '',
'submit_btn': 'Отправить',
})
headers = {"User-Agent" : "Opera/9.64 (Windows NT 5.1; U; en) Presto/2.1.1",
"Accept" : "text/html, application/xml;q=0.9, application/xhtml+xml, image/png, image/jpeg, image/gif, image/x-xbitmap, */*;q=0.1",
"Accept-Language" : "ru,uk-UA;q=0.9,uk;q=0.8,en;q=0.7",
"Accept-Charset" : "iso-8859-1, utf-8, utf-16, *;q=0.1",
"Accept-Encoding" : "identity, *;q=0",
"Connection" : "Keep-Alive",
"Referer" : "http://pythonerblog.ya.ru/posts_add_text.xml"}
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookies))
urllib2.install_opener(opener)
req = urllib2.Request(myya_posting_url, data, headers)
page2 = urllib2.urlopen(req).read()
cook = authorization()
posting(cook)