Skip to content

Instantly share code, notes, and snippets.

@ninehills
Created August 25, 2012 10:37
Show Gist options
  • Save ninehills/3463463 to your computer and use it in GitHub Desktop.
Save ninehills/3463463 to your computer and use it in GitHub Desktop.
check_google_ip
#!/usr/bin/env python
# coding:utf-8
import sys
import os
import re
import gevent
import gevent.monkey
import gevent.timeout
gevent.monkey.patch_all()
import urllib2
def check_ip(ip):
try:
with gevent.timeout.Timeout(5):
response = urllib2.urlopen('http://%s/' % ip)
text = response.read()
if 'google' in text:
print ip
except gevent.timeout.Timeout as e:
pass
except Exception as e:
pass
def main():
greenlets = [gevent.spawn(check_ip, '203.208.46.%d' % i) for i in xrange(1, 256)]
gevent.joinall(greenlets)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment