Last active
August 29, 2015 13:55
-
-
Save cjlano/8692137 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# DuckDuckGo (sudo pip install duckduckgo) | |
>>> import duckduckgo | |
>>> r = duckduckgo.query("ip address") | |
>>> r.answer.text | |
'Your IP address is ...' | |
>>> import re | |
>>> address_regexp = re.compile ('\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}') | |
>>> result = address_regexp.search( r.answer.text ) | |
>>> result.group() | |
'xx.xx.xx.xxx' | |
# DynDNS | |
>>> import urllib2 | |
>>> ip_checker_url = "http://checkip.dyndns.org/" | |
>>> response = urllib2.urlopen(ip_checker_url).read() | |
>>> result = address_regexp.search(response) | |
>>> result.group() | |
'xx.xx.xx.xxx' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment