Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'www.ip.cn失效,更改ip获取方式' #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 4 additions & 10 deletions aliyun_ddns.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,16 +89,10 @@ def update_yun(ip):
print result

def get_curr_ip():
headers = {
'content-type': 'text/html',
'User-Agent': 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:22.0) Gecko/20100101 Firefox/22.0'
}
resp = requests.get('https://www.ip.cn/', headers=headers)
soup = BS(resp.content, 'html.parser')
for t in soup.find_all('code'):
if re.search(r"^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$", t.string):
return t.string
return ''
url = urllib.urlopen("http://txt.go.sohu.com/ip/soip")
text = url.read()
ip = re.findall(r'\d+.\d+.\d+.\d+', text)
return ip[0]

def get_lastest_local_ip():
"""
Expand Down