import urllib2 import re attacker=open('Attacker.txt', 'r').read() for line in attacker: ip = attacker req = urllib2.Request('http://www.geoiptool.com/en/?IP=' + ip) response = urllib2.urlopen(req) the_page = response.readlines() print line #print the_page ### ### ### ### #COUNTRY country = the_page[173] cntry=country x = re.search('> *([^>]+) *</a>', cntry) print x.group(1) ### ### ### ### #LONG long = the_page[197] lineof_long=long.split() section_long=lineof_long[2] print section_long[19:-5] ### ### ### ### #LAT long = the_page[201] lineof_long=long.split() section_long=lineof_long[2] print section_long[19:-5]
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question