根据ip获取同ip域名

import http.cookiejar
import urllib.request
class getSignal():
    def __init__(self):
        self.cookieJar = http.cookiejar.LWPCookieJar() 
        opener = urllib.request.build_opener(urllib.request.HTTPCookieProcessor(self.cookieJar))
        urllib.request.install_opener(opener)
    def get(self,ip):
        url='http://domains.yougetsignal.com/domains.php'
        data = {
            'remoteAddress': ip,
            'key': '',
        }  
        headers={
         'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36',
         'Referer':'http://www.yougetsignal.com/tools/web-sites-on-web-server/'
        }
        post_data = urllib.parse.urlencode(data).encode(encoding='UTF8')
        request = urllib.request.Request(url,data=post_data,headers=headers)
        request = urllib.request.urlopen(request)
        pageHtml = request.read().decode('UTF-8')
        request.close()
        print(pageHtml)
if __name__ == '__main__':
    s = getSignal();
    s.get('122.114.91.173')

比站长之家的好用

你可能感兴趣的:(Linux运维)