|
@@ -2,30 +2,32 @@ import requests
|
|
from bs4 import BeautifulSoup
|
|
from bs4 import BeautifulSoup
|
|
import re
|
|
import re
|
|
|
|
|
|
|
|
+
|
|
def getIpFromIpaddress(site):
|
|
def getIpFromIpaddress(site):
|
|
headers = {'user-agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebkit/737.36(KHTML, like Gecke) Chrome/52.0.2743.82 Safari/537.36',
|
|
headers = {'user-agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebkit/737.36(KHTML, like Gecke) Chrome/52.0.2743.82 Safari/537.36',
|
|
- 'Host': 'ipaddress.com' }
|
|
|
|
|
|
+ 'Host': 'ipaddress.com'}
|
|
url = "https://ipaddress.com/search/" + site
|
|
url = "https://ipaddress.com/search/" + site
|
|
trueip = None
|
|
trueip = None
|
|
try:
|
|
try:
|
|
- res = requests.get(url,headers=headers,timeout=2)
|
|
|
|
|
|
+ res = requests.get(url, headers=headers, timeout=2)
|
|
soup = BeautifulSoup(res.text, 'html.parser')
|
|
soup = BeautifulSoup(res.text, 'html.parser')
|
|
- ip = re.findall(r"\b(?:[0-9]{1,3}\.){3}[0-9]{1,3}\b", c.text)
|
|
|
|
|
|
+ ip = re.findall(r"\b(?:[0-9]{1,3}\.){3}[0-9]{1,3}\b", res.text)
|
|
result = soup.find_all('div', class_="comma-separated")
|
|
result = soup.find_all('div', class_="comma-separated")
|
|
for c in result:
|
|
for c in result:
|
|
if len(ip) != 0:
|
|
if len(ip) != 0:
|
|
trueip = ip[0]
|
|
trueip = ip[0]
|
|
except Exception as e:
|
|
except Exception as e:
|
|
- print("查询" + site + " 时出现错误: "+str(e))
|
|
|
|
|
|
+ print("查询" + site + " 时出现错误: " + str(e))
|
|
return trueip
|
|
return trueip
|
|
|
|
|
|
|
|
+
|
|
def getIpFromChinaz(site):
|
|
def getIpFromChinaz(site):
|
|
headers = {'user-agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebkit/737.36(KHTML, like Gecke) Chrome/52.0.2743.82 Safari/537.36',
|
|
headers = {'user-agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebkit/737.36(KHTML, like Gecke) Chrome/52.0.2743.82 Safari/537.36',
|
|
- 'Host': 'ip.tool.chinaz.com' }
|
|
|
|
|
|
+ 'Host': 'ip.tool.chinaz.com'}
|
|
url = "http://ip.tool.chinaz.com/" + site
|
|
url = "http://ip.tool.chinaz.com/" + site
|
|
trueip = None
|
|
trueip = None
|
|
try:
|
|
try:
|
|
- res = requests.get(url,headers=headers)
|
|
|
|
|
|
+ res = requests.get(url, headers=headers)
|
|
soup = BeautifulSoup(res.text, 'html.parser')
|
|
soup = BeautifulSoup(res.text, 'html.parser')
|
|
result = soup.find_all('span', class_="Whwtdhalf w15-0")
|
|
result = soup.find_all('span', class_="Whwtdhalf w15-0")
|
|
for c in result:
|
|
for c in result:
|
|
@@ -33,21 +35,21 @@ def getIpFromChinaz(site):
|
|
if len(ip) != 0:
|
|
if len(ip) != 0:
|
|
trueip = ip[0]
|
|
trueip = ip[0]
|
|
except Exception as e:
|
|
except Exception as e:
|
|
- print("查询" + site + " 时出现错误: "+str(e))
|
|
|
|
|
|
+ print("查询" + site + " 时出现错误: " + str(e))
|
|
return trueip
|
|
return trueip
|
|
|
|
|
|
|
|
|
|
def getIpFromWhatismyipaddress(site):
|
|
def getIpFromWhatismyipaddress(site):
|
|
headers = {'user-agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebkit/737.36(KHTML, like Gecke) Chrome/52.0.2743.82 Safari/537.36',
|
|
headers = {'user-agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebkit/737.36(KHTML, like Gecke) Chrome/52.0.2743.82 Safari/537.36',
|
|
- 'Host': 'ip.tool.chinaz.com' }
|
|
|
|
|
|
+ 'Host': 'ip.tool.chinaz.com'}
|
|
url = "https://whatismyipaddress.com//hostname-ip"
|
|
url = "https://whatismyipaddress.com//hostname-ip"
|
|
- data={
|
|
|
|
- "DOMAINNAME":site,
|
|
|
|
|
|
+ data = {
|
|
|
|
+ "DOMAINNAME": site,
|
|
"Lookup IP Address": "Lookup IP Address"
|
|
"Lookup IP Address": "Lookup IP Address"
|
|
}
|
|
}
|
|
trueip = None
|
|
trueip = None
|
|
try:
|
|
try:
|
|
- res = requests.post(url,headers=headers,data=data)
|
|
|
|
|
|
+ res = requests.post(url, headers=headers, data=data)
|
|
soup = BeautifulSoup(res.text, 'html.parser')
|
|
soup = BeautifulSoup(res.text, 'html.parser')
|
|
result = soup.find_all('span', class_="Whwtdhalf w15-0")
|
|
result = soup.find_all('span', class_="Whwtdhalf w15-0")
|
|
for c in result:
|
|
for c in result:
|
|
@@ -55,5 +57,5 @@ def getIpFromWhatismyipaddress(site):
|
|
if len(ip) != 0:
|
|
if len(ip) != 0:
|
|
trueip = ip[0]
|
|
trueip = ip[0]
|
|
except Exception as e:
|
|
except Exception as e:
|
|
- print("查询" + site + " 时出现错误: "+str(e))
|
|
|
|
|
|
+ print("查询" + site + " 时出现错误: " + str(e))
|
|
return trueip
|
|
return trueip
|