Skip to content

Instantly share code, notes, and snippets.

View higs4281's full-sized avatar

william higgins higs4281

  • Consumer Financial Protection Bureau
View GitHub Profile
@higs4281
higs4281 / gist:3378487
Created August 17, 2012 12:36
widget string
prestring=['MugShotWidget2.serverResponse([\' <div class="ms_outer_container"><a href="http://www.tampabay.com/mugshots/" target="_blank"><img src="http://mugshots.s3.amazonaws.com/site-images/widget-header.gif" alt="Tampa Bay Mug Shots" /></a><div class="ms_toptext">Meet the latest eight people booked in Pinellas, Hillsborough, Manatee and Pasco counties.</div>']
poststring=[]
for each in mugs:
pair = "%s %s" % (each.first_name, each.last_name)
poststring.append('<a href="http://www.tampabay.com/mugshots/" target="_blank"><img class="ms_mug" src="%s" title="%s" alt="%s" /></a>' % (each.signed_photo, pair, pair))
for each in poststring:
prestring.append(each)
widget = "".join(prestring)+"\'])"
import re
def kml_fixer(DIRECTORY, FILENAME):
file_in=DIRECTORY+'/'+FILENAME
file_out=DIRECTORY+'/NEW_'+FILENAME
with open(file_in, "r+") as f:
old = f.read()
x = re.findall(r'<Point>\n.*\n.*<\/Point>', old)
for each in x:
old = old.replace(each, "")
@higs4281
higs4281 / gist:1961817
Created March 2, 2012 22:18
bs4 crime scrape
from bs4 import BeautifulSoup
import requests
import csv
url = "http://www.crimemapping.com/DetailedReport.aspx?db=1/12/2012+00:00:00&de=1/25/2012+23:59:00&ccs=AR,AS,BU,DP,DR,DU,FR,HO,VT,RO,SX,TH,VA,VB,WE&xmin=-8577539.984326074&ymin=4369220.056681086&xmax=-8402193.441439813&ymax=4444739.840626868&faid=0b80bce5-5d21-468b-ae81-3d6e2ecf532e"
r = requests.get(url)
soup = BeautifulSoup(r.text)
table = soup.findAll('table')[0]
crimelist = []
for row in table.findAll('tr')[1:]: