Copy Source | Copy HTML def initialize (self): connection = httplib .HTTPConnection( 'www.yandex.ru' ) connection.request( 'GET' , '/' ) response = connection.getresponse() cookies = response.getheader( 'set-cookie' , None) response.close() match = re .search( '(?<=yandexuid=)[^;]*' , cookies) self ._yandexuid = match.group( 0 ) print 'yandexuid =' , self ._yandexuid
Copy Source | Copy HTML def initialize (self): connection = httplib .HTTPConnection( 'www.yandex.ru' ) connection.request( 'GET' , '/' ) response = connection.getresponse() cookies = response.getheader( 'set-cookie' , None) response.close() match = re .search( '(?<=yandexuid=)[^;]*' , cookies) self ._yandexuid = match.group( 0 ) print 'yandexuid =' , self ._yandexuid
Copy Source | Copy HTML def initialize (self): connection = httplib .HTTPConnection( 'www.yandex.ru' ) connection.request( 'GET' , '/' ) response = connection.getresponse() cookies = response.getheader( 'set-cookie' , None) response.close() match = re .search( '(?<=yandexuid=)[^;]*' , cookies) self ._yandexuid = match.group( 0 ) print 'yandexuid =' , self ._yandexuid
Copy Source | Copy HTML def initialize (self): connection = httplib .HTTPConnection( 'www.yandex.ru' ) connection.request( 'GET' , '/' ) response = connection.getresponse() cookies = response.getheader( 'set-cookie' , None) response.close() match = re .search( '(?<=yandexuid=)[^;]*' , cookies) self ._yandexuid = match.group( 0 ) print 'yandexuid =' , self ._yandexuid
Copy Source | Copy HTML def initialize (self): connection = httplib .HTTPConnection( 'www.yandex.ru' ) connection.request( 'GET' , '/' ) response = connection.getresponse() cookies = response.getheader( 'set-cookie' , None) response.close() match = re .search( '(?<=yandexuid=)[^;]*' , cookies) self ._yandexuid = match.group( 0 ) print 'yandexuid =' , self ._yandexuid
Copy Source | Copy HTML def initialize (self): connection = httplib .HTTPConnection( 'www.yandex.ru' ) connection.request( 'GET' , '/' ) response = connection.getresponse() cookies = response.getheader( 'set-cookie' , None) response.close() match = re .search( '(?<=yandexuid=)[^;]*' , cookies) self ._yandexuid = match.group( 0 ) print 'yandexuid =' , self ._yandexuid
Copy Source | Copy HTML def initialize (self): connection = httplib .HTTPConnection( 'www.yandex.ru' ) connection.request( 'GET' , '/' ) response = connection.getresponse() cookies = response.getheader( 'set-cookie' , None) response.close() match = re .search( '(?<=yandexuid=)[^;]*' , cookies) self ._yandexuid = match.group( 0 ) print 'yandexuid =' , self ._yandexuid
Copy Source | Copy HTML def initialize (self): connection = httplib .HTTPConnection( 'www.yandex.ru' ) connection.request( 'GET' , '/' ) response = connection.getresponse() cookies = response.getheader( 'set-cookie' , None) response.close() match = re .search( '(?<=yandexuid=)[^;]*' , cookies) self ._yandexuid = match.group( 0 ) print 'yandexuid =' , self ._yandexuid
Copy Source | Copy HTML def initialize (self): connection = httplib .HTTPConnection( 'www.yandex.ru' ) connection.request( 'GET' , '/' ) response = connection.getresponse() cookies = response.getheader( 'set-cookie' , None) response.close() match = re .search( '(?<=yandexuid=)[^;]*' , cookies) self ._yandexuid = match.group( 0 ) print 'yandexuid =' , self ._yandexuid
Copy Source | Copy HTML def initialize (self): connection = httplib .HTTPConnection( 'www.yandex.ru' ) connection.request( 'GET' , '/' ) response = connection.getresponse() cookies = response.getheader( 'set-cookie' , None) response.close() match = re .search( '(?<=yandexuid=)[^;]*' , cookies) self ._yandexuid = match.group( 0 ) print 'yandexuid =' , self ._yandexuid
Copy Source | Copy HTML
- def login (self):
- content = 'login = {0} & passwd = {1} & timestamp = {2}'
- content = content.format ( self ._login, self ._passwd, self .timestamp ())
- connection = httplib .HTTPConnection ( 'passport.yandex.ru' )
- connection.request ( 'POST' , '/ passport? mode = auth' , content, { 'Cookie' : self .getcookies ()})
- response = connection.getresponse ()
- content = response.read ()
- response.close ()
- match = re .search ( 'idkey \ "\ s. *' , content)
- match = re .search ( '(\ d \ w *)' , match.group ( 0 ))
- self ._idkey = match.group ( 0 )
- print 'idkey =' , self ._idkey
Copy Source | Copy HTML
- def authenticate (self):
- content = 'filled = yes & timestamp = {0} & idkey = {1} & no =% D0% 9D% D0% B5% D1% 82'
- content = content.format ( self .timestamp (), self ._idkey)
- connection = httplib .HTTPConnection ( 'passport.yandex.ru' )
- connection.request ( 'POST' , '/ passport? mode = auth' , content, { 'Cookie' : self .getcookies ()})
- response = connection.getresponse ()
- cookies = response.getheader ( 'set-cookie' , None)
- ... parsing cookies with regexps ...
- response.close ()
Copy Source | Copy HTML
- def updatedomain (self, ns_record_id):
- content = 'domain = {0} & ns_record_id = {1} & ns_rec_type = A & ns_subdomain =% 40 & ns_weight = & ns_port = & ns_content = {2} & ns_priority = 1'
- content = content.format ( self ._domain, ns_record_id, self ._externalip)
- connection = httplib .HTTPSConnection ( 'pdd.yandex.ru' )
- connection.request ( 'POST' , '/ajax/ns_simple_record_edit.ajax.xml' , content, \
- { 'Accept' : 'application / json, text / javascript, * / *' , \
- 'Cookie' : self .getcookies ()})
- response = connection.getresponse ()
- response.close ()
Copy Source | Copy HTML
- def domainlist (self):
- connection = httplib .HTTPSConnection ( 'pdd.yandex.ru' )
- connection.request ( 'GET' , '/ domain_ns / {0} /' .format ( self ._domain), None, \
- { 'Accept' : 'text / html, application / xhtml + xml, application / xml; q = 0.9, * / *; q = 0.8' , \
- 'Cookie' : self .getcookies (), \
- 'Referer' : 'https://pdd.yandex.ru' })
- response = connection.getresponse ()
- content = response.read ()
- block = re .findall ( 'item: \ s \' [\ d] + \ '(. +) value = "[\ w \.] +"' , content)
- for item in block:
- match = re .search ( '(? <= item: \ s \') [\ d] * ' , item)
- ns_record_id = match.group ( 0 )
- match = re .search ( 'ns_subdomain (. +?) value = \ "(. +?) \"' , item)
- match = re .search ( '(? <= value =) \ ". +? \"' , match.group ( 0 ))
- ns_subdomain = match.group ( 0 )
- match = re .search ( 'ns_rec_type (. +?) value = \ "(. +?) \"' , item)
- match = re .search ( '(? <= value =) \ ". +? \"' , match.group ( 0 ))
- ns_rec_type = match.group ( 0 )
- match = re .search ( 'ns_content (. +?) value = \ "(. +?) \"' , item)
- match = re .search ( '(? <= value =) \ ". +? \"' , match.group ( 0 ))
- ns_content = match.group ( 0 )
- record = 'ns_record_id = {0} | ns_subdomain = {1} | ns_rec_type = {2} | ns_content = {3} '
- print record.format (ns_record_id, ns_subdomain, ns_rec_type, ns_content)
- response.close ()
Source: https://habr.com/ru/post/122877/
All Articles