This file contains hidden or 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
| #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: |
This file contains hidden or 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
| #download-searches.py | |
| import obo | |
| query = 'mulatto*+negro*' | |
| obo.getSearchResults(query, "advanced", "1700", "00", "1750", "99", 13) |
This file contains hidden or 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
| 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 |
This file contains hidden or 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
| #download-searches.py | |
| import obo | |
| query = 'mulatto*+negro*' | |
| obo.getSearchResults(query, "advanced", "1700", "00", "1750", "99") |
This file contains hidden or 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
| http://www.oldbaileyonline.org/browse.jsp?id=t17160113-18&div=t17160113-18&terms=mulatto|negro#highlight |
This file contains hidden or 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
| mulatto*+negro* |
This file contains hidden or 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
| 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 |
This file contains hidden or 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
| 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: |
This file contains hidden or 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
| 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/...' |
This file contains hidden or 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
| #download-searches.py | |
| import obo | |
| query = 'mulatto*+negro*' | |
| obo.getSearchResults(query, "advanced", "1700", "00", "1750", "99", 13) | |
| obo.getIndivTrials(query) |