Created
December 27, 2011 16:36
-
-
Save XayOn/1524278 to your computer and use it in GitHub Desktop.
Wigle.net Parser
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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
""" | |
Based on http://github.com/XayOn/Python-tuenti | |
Login class because of extreme lazyness. | |
Copyright (C) 2011 David Francos Cuartero (XayOn) | |
Made for thex1le who was working on this idea with urllib2. | |
This software is GPL2+ | |
""" | |
import mechanize, urllib, re, urlparse | |
from BeautifulSoup import BeautifulSoup, SoupStrainer | |
urls = { 'login': "https://wigle.net//gps/gps/main/login", | |
'initial': "http://wigle.net", | |
'query': 'http://wigle.net/gps/gps/main/confirmquery/' | |
} | |
class Wigle(object): | |
def __init__(self, username, password): | |
self._br = mechanize.Browser() | |
self._br.open(urls['initial']) | |
self.encoded_data = urllib.urlencode({'credential_0': username, | |
'credential_1': password}) | |
self.response = self._br.open(urls['login'], self.encoded_data).read() | |
def _filter(self, stuff): | |
return BeautifulSoup(self._br.open(urls['query'], stuff).read(), | |
parseOnlyThese=SoupStrainer('table')).findAll('a') | |
def _query(self, stuff): | |
stuff=urllib.urlencode(stuff) | |
return [ urlparse.urlparse(i['href']).query for i in _filter(stuff)\ | |
if "Get Map" in i.contents ] | |
def query(self, stuff): | |
return [ i.split('&') for i in [a for a in self._query(stuff) ] ] | |
if __name__ == "__main__": | |
import sys, argparse | |
parser = argparse.ArgumentParser(description='Get access point searches based on wigle.net data') | |
parser.add_argument('--addresscode', default="", dest='addresscode', help='addresscode') | |
parser.add_argument('--statecode', default="", dest='statecode', help='statecode') | |
parser.add_argument('--zipcode', default="", dest='zipcode', help='zipcode') | |
parser.add_argument('--variance', default="", dest='variance', help='variance') | |
parser.add_argument('--latrange1', default="", dest='latrange1', help='latrange1') | |
parser.add_argument('--latrange', default="", dest='latrange', help='latrange') | |
parser.add_argument('--longrange1', default="", dest='longrange1', help='longrange1') | |
parser.add_argument('--longrange2', default="", dest='longrange2', help='longrange2') | |
parser.add_argument('--lastupdt', default="", dest='lastupdt', help='lastupdt') | |
parser.add_argument('--netid', default="", dest='netid', help='netid') | |
parser.add_argument('--ssid', default="", dest='ssid', help='ssid') | |
parser.add_argument('--query', default="", dest='query', help='Query') | |
parser.add_argument('--username', default="", dest='username', help='Wigle.net username') | |
parser.add_argument('--password', default="", dest='password', help='Wigle.net password') | |
options = parser.parse_args() | |
print(Wigle(options.username, options.password).query( | |
{ | |
"addresscode":options.addresscode, | |
"statecode":options.statecode, | |
"zipcode":options.zipcode, | |
"variance":options.variance, | |
"latrange1":options.latrange1, | |
"latrange":options.latrange, | |
"longrange1":options.longrange1, | |
"longrange2":options.longrange2, | |
"lastupdt":options.lastupdt, | |
"netid":options.netid, | |
"ssid":options.ssid, | |
"Query":options.query | |
} | |
)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment