Skip to content

Instantly share code, notes, and snippets.

View acrymble's full-sized avatar

Adam Crymble acrymble

  • London
View GitHub Profile
@acrymble
acrymble / getSearchResults.py
Created October 10, 2011 14:17
Get Search Results pages OBO - Function
#create URLs for search results pages and save the files
def getSearchResults(query, kwparse, fromYear, fromMonth, toYear, toMonth, entries):
import urllib2
startValue = 0
#determine how many files need to be downloaded.
pageCount = entries / 10
remainder = entries % 10
if remainder > 0:
@acrymble
acrymble / download searches.py
Created October 10, 2011 14:23
download searches.py
#download-searches.py
import obo
query = 'mulatto*+negro*'
obo.getSearchResults(query, "advanced", "1700", "00", "1750", "99", 13)
@acrymble
acrymble / getSearchResults.py
Created October 10, 2011 15:04
Get Search Results page OBO - Function
def getSearchResults(query, kwparse, fromYear, fromMonth, toYear, toMonth):
import urllib2
startValue = 0
#each part of the URL. Split up to be easier to read.
url = 'http://www.oldbaileyonline.org/search.jsp?foo=bar&form=searchHomePage&_divs_fulltext='
url += query
url += '&kwparse=' + kwparse
@acrymble
acrymble / download searches.py
Created October 10, 2011 15:10
download-searches.py
#download-searches.py
import obo
query = 'mulatto*+negro*'
obo.getSearchResults(query, "advanced", "1700", "00", "1750", "99")
@acrymble
acrymble / anne-smith.html
Created October 10, 2011 15:36
Anne Smith Link
http://www.oldbaileyonline.org/browse.jsp?id=t17160113-18&div=t17160113-18&terms=mulatto|negro#highlight
@acrymble
acrymble / search query
Created October 10, 2011 15:41
Search Query
mulatto*+negro*
@acrymble
acrymble / getIndiviTrials.py
Created October 10, 2011 17:20
getIndivTrials
def getIndivTrials(query):
import os
dirPath = #add the path to your 'programming-historian' directory here
#for PC it should start with: 'C:\\Documents and Settings...'
#for Mac it should start with: '/Users/...'
searchResults = os.listdir(dirPath + query)
print searchResults
@acrymble
acrymble / getIndiviTrials2.py
Created October 10, 2011 17:25
getIndivTrials2
def getIndivTrials(query):
#...
urls = []
for files in searchResults:
if files.find("search-result") != -1:
f = open(query + "/" + files, 'r')
text = f.read().split(" ")
f.close()
for words in text:
@acrymble
acrymble / getIndivTrials.py
Created October 10, 2011 18:52
getIndivTrials complete
def getIndivTrials(query):
import os, urllib2, time
#import built-in python functions for building file paths
from os.path import join as pjoin
#find the search results pages in the new directory.
dirPath = #add the path to your 'programming-historian' directory here
#for PC it should start with: 'C:\\Documents and Settings...'
#for Mac it should start with: '/Users/...'
@acrymble
acrymble / download-searches2.py
Created October 10, 2011 18:56
download-searches2.py
#download-searches.py
import obo
query = 'mulatto*+negro*'
obo.getSearchResults(query, "advanced", "1700", "00", "1750", "99", 13)
obo.getIndivTrials(query)