авторизация на сайте

 
0
 
Python
ava
GELEAF | 19.05.2010, 19:43
Есть сай 999.md, там нужно залогинится...вот Get запрос

<REQUEST>
<HEADERS>
<HEADER name="(Method-Line)" value="POST /Login/ HTTP/1.1"/>
<HEADER name="Accept" value="image/gif, image/jpeg, image/pjpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, application/x-ms-application, application/x-ms-xbap, application/vnd.ms-xpsdocument, application/xaml+xml, */*"/>
<HEADER name="Referer" value="http://999.md/Login/"/>
<HEADER name="Accept-Language" value="ru"/>
<HEADER name="User-Agent" value="Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; MRA 5.6 (build 03402); InfoPath.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)"/>
<HEADER name="Content-Type" value="application/x-www-form-urlencoded"/>
<HEADER name="Accept-Encoding" value="gzip, deflate"/>
<HEADER name="Host" value="999.md"/>
<HEADER name="Content-Length" value="2026"/>
<HEADER name="Connection" value="Keep-Alive"/>
<HEADER name="Cache-Control" value="no-cache"/>
<HEADER name="Cookie" value="LANGUAGE=ru-RU; ASP.NET_SessionId=fnev4sdyuvmwzd4kak2asa4a; REGION=0; __utma=117578817.942382764.1274226329.1274226329.1274226329.1; __utmb=117578817; __utmc=117578817; __utmz=117578817.1274226329.1.1.utmccn=(direct)|utmcsr=(direct)|utmcmd=(none)"/>
</HEADERS>
<POSTDATA mimetype="application/x-www-form-urlencoded">
<RAW>
<![CDATA[__EVENTTARGET=&__EVENTARGUMENT=&__VIEWSTATE=%2FwEPDwUKMTU1NDAxODgzOA9kFgJmD2QWAgIBD2QWDmYPFQE%2BPHNjcmlwdCBzcmM9Imh0dHA6Ly9wcm9tby5tZC9Ub29sYmFyL0RlZi5hc3B4P0lEPTk5Ij48L3NjcmlwdD5kAgIPZBYCZg8VAT48c2NyaXB0IHNyYz0iaHR0cDovL3Byb21vL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QoJ2N0bDAwX01haW4zX0J1dHRvbjEnLGV2ZW50KTtkAgIPDxYCHwEFQ9Cd0LUg0L%2FRgNCw0LLQuNC70YzQvdC%2BINCy0LLQtdC00LXQvSDQu9C%2B0LPQuNC9INC40LvQuCDQv9Cw0YDQvtC70YxkZAIDDw9kFgQfAwU6TWFya2V0X1Nob3dEaXZUZXh0KCdjdGwwMF9NYWluM19kaXYxJywnY3RsMDBfTWFpbjNfdGlwcycpOx8EBStNYXJrZXRfU3VibWl0KCdjdGwwMF9NYWluM19CdXR0b24xJyxldmVudCk7ZAIFDxUBH9CX0LDQv9C%2B0LzQvdC40YLRjCDQv9Cw0YDQvtC70YxkAgYPDxYCHgtOYXZpZ2F0ZVVybAUTL0xvZ2luL1Jlc3RvcmUuYXNweGRkAgcPDxYCHwEFCtCS0L7QudGC0LhkZAIIDw8WAh8BZWRkAgsPFQEHL0Jhc2tldGQYAQUeX19Db250cm9sc1JlcXVpcmVQb3N0QmFja0tleV9fFgEFFWN0bDAwJE1haW4zJENoZWNrQm94MT5JFFmPE782ZTqHwQkFx4xelaGXQAwDWHOAWup%2FZ%2FAW&ctl00%24th%24tbSearch=&ctl00%24Main3%24TextBox1=qzer&ctl00%24Main3%24TextBox2=290590&ctl00%24Main3%24Button1=%D0%92%D0%BE%D0%B9%D1%82%D0%B8]]>
</RAW>
<PARAMETER name="__EVENTTARGET" value=""/>
<PARAMETER name="__EVENTARGUMENT" value=""/>
<PARAMETER name="__VIEWSTATE" value="%2FwEPDwUKMTU1NDAxODgzOA9kFgJmD2QWAgIBD2QWDmYPFQE%2BPHNjcmlwdCBzcmM9Imh0dHA6Ly9wcm9tby5tZC9Ub29sYmFyL0RlZi5hc3B4P0lEPTk5Ij48L3NjcmlwdD5kAgIPZBYCZg8VAT48c2NyaXB0IHNyYz0iaHR0cDovL3Byb21vLm1kL1Nob3dzL0QxLmFzcHg%2FUklEPTEwOTQiPjwvc2NyaXB0PmQCAw9kFhJmDxYCHgdWaXNpYmxlaBY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C70YzQvdC%2BINCy0LLQtdC00LXQvSDQu9C%2B0LPQuNC9INC40LvQuCDQv9Cw0YDQvtC70YxkZAIDDw9kFgQfAwU6TWFya2V0X1Nob3dEaXZUZXh0KCdjdGwwMF9NYWluM19kaXYxJywnY3RsMDBfTWFpbjNfdGlwcycpOx8EBStNYXJrZXRfU3VibWl0KCdjdGwwMF9NYWluM19CdXR0b24xJyxldmVudCk7ZAIFDxUBH9CX0LDQv9C%2B0LzQvdC40YLRjCDQv9Cw0YDQvtC70YxkAgYPDxYCHgtOYXZpZ2F0ZVVybAUTL0xvZ2luL1Jlc3RvcmUuYXNweGRkAgcPDxYCHwEFCtCS0L7QudGC0LhkZAIIDw8WAh8BZWRkAgsPFQEHL0Jhc2tldGQYAQUeX19Db250cm9sc1JlcXVpcmVQb3N0QmFja0tleV9fFgEFFWN0bDAwJE1haW4zJENoZWNrQm94MT5JFFmPE782ZTqHwQkFx4xelaGXQAwDWHOAWup%2FZ%2FAW"/>
<PARAMETER name="ctl00%24th%24tbSearch" value=""/>
<PARAMETER name="ctl00%24Main3%24TextBox1" value="qzer"/>
<PARAMETER name="ctl00%24Main3%24TextBox2" value="123"/>
<PARAMETER name="ctl00%24Main3%24Button1" value="%D0%92%D0%BE%D0%B9%D1%82%D0%B8"/>
</POSTDATA>
</REQUEST>


а это код скрпта:

# -*- coding: utf-8 -*-
import urllib, urllib2, cookielib
cj = cookielib.CookieJar()
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
urllib2.install_opener(opener)
login = 'pythontest'
passwd = 'qwerty'
__EVENTTARGET = ''
__EVENTARGUMENT = ''
#__VIEWSTATE = '%2FwEPDwUKMTU1NDAxODgzOA9kFgJmD2QWAgIBD2QWDmYPFQE%2BPHNjcmlwdCBzcmM9Imh0dHA6Ly9wcm9tby5tZC9Ub29sYmFyL0RlZi5hc3B4P0lEPTk5Ij48L3NjcmlwdD5kAgIPZBYCZg8VAT48c2NyaXB0IHNyYz0iaHR0cDovL3Byb21vL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CgnY3RsMDBfTWFpbjNfQnV0dG9uMScsZXZlbnQpO2QCBQ8VAR/Ql9Cw0L/QvtC80L3QuNGC0Ywg0L/QsNGA0L7Qu9GMZAIGDw8WAh4LTmF2aWdhdGVVcmwFEy9Mb2dpbi9SZXN0b3JlLmFzcHhkZAIHDw8WAh8BBQrQktC+0LnRgtC4ZGQCCA8PFgIfAWVkZAILDxUBBy9CYXNrZXRkGAEFHl9fQ29udHJvbHNSZXF1aXJlUG9zdEJhY2tLZXlfXxYBBRVjdGwwMCRNYWluMyRDaGVja0JveDHylJeKUQwYFUY0STWbJpykFBsg1l2cjUoGgHIC7Z+kfQ=='
searc = ''
login_url = 'http://999.md/Login/'
target_url = 'http://999.md/Profile/Replenish/'
data = {'__EVENTTARGET': '', '__EVENTARGUMENT': '', '__VIEWSTATE':__VIEWSTATE, 'ctl00%24th%24tbSearch':'', 'ctl00%24Main3%24TextBox1':login, 'ctl00%24Main3%24TextBox2':passwd, 'ctl00%24Main3%24Button1':'%D0%92%D0%BE%D0%B9%D1%82%D0%B8' }
#data = {'login': login, 'pass': passwd}
encoded_data = urllib.urlencode(data)

f = opener.open(login_url, encoded_data)
#f.close()

#f = opener.open(target_url)

print f.read().decode('utf8')



код редиректит на страницу залогинивания...помогите понять ошибку...
Kommentare (0)

Kommentare werden nicht hinzugefügt

Registrieren Sie sich oder melden Sie sich an, um schreiben zu können.
Unternehmen des Tages
Вы также можете добавить свою фирму в каталог IT-фирм, и публиковать статьи, новости, вакансии и другую информацию от имени фирмы.
Подробнее
Mitwirkende
  GELEAF
advanced
Absenden