Created
August 12, 2012 21:21
-
-
Save DamianZaremba/3334541 to your computer and use it in GitHub Desktop.
Get the current cloudflare ip ranges
This file contains hidden or 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
#!/usr/bin/python | |
import urllib2 | |
from BeautifulSoup import BeautifulSoup | |
if __name__ == "__main__": | |
try: | |
response = urllib2.urlopen("https://www.cloudflare.com/wiki/index.php"\ | |
"?title=What_are_the_CloudFlare_IP_address"\ | |
"_ranges&action=render") | |
except urllib2.HTTPError, e: | |
print "Could not grab page, server returned %d" % e.code | |
except urllib2.URLError, e: | |
print "Could not reach the server to grab page: %s" % e.reason | |
else: | |
data = response.read() | |
soup = BeautifulSoup(data) | |
for range in soup.findAll('li'): | |
slash = range.string.split(' ')[0] | |
print slash |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment