def setSchoolDetails(self): for schoolID in self.schoolIDs: url = "http://www.education.gov.uk/schools/performance/school/{}".format(schoolID) content = getPage(url) soup = BeautifulSoup(content) queries = ["Head","Street","Town","Postcode","Telephone number"] try: name = getName(soup) attrObject = getItems(soup,queries) date,grade,link = getOfsted(soup) except PageError: continue school = SchoolObject(schoolID) school.url = url school.setName(name) school.setAttr(attrObject) school.setOfsted(date,grade,link) self.schools.append(school)
def getOfstead(self): url = self.school.report content = getPage(url) soup = BeautifulSoup(content) div = soup.find(class_="download-report-link") if not div: print("Error for school {}".format(self.school)) return link = div.find("a") urlPath = link["href"] urlBase = "http://reports.ofsted.gov.uk" url = urlBase + urlPath report = getPDF(url) savePDF(self.filename(),report)
def searchSchools(self): """Searches for schools using the configuration given previously the school IDs are stored as a class varaibles for later use """ urlBase = "http://schoolsfinder.direct.gov.uk" urlPath = "/school-location-search-results-json/&" params = ( ("searchString", self.postcode), ("distanceValue", self.distance) ) urlParams = urllib.parse.urlencode(params) url = urlBase+urlPath+urlParams pageContent = getPage(url) self.setSchools(pageContent)
def getOfstead(self): url = self.school.report content = getPage(url) soup = BeautifulSoup(content) div = soup.find(class_="download-report-link") if not div: print("Error for school {}".format(self.school)) return link = div.find("a") urlPath = link["href"] urlBase = "http://reports.ofsted.gov.uk" url = urlBase + urlPath report = getPDF(url) savePDF(self.filename(), report)
def searchSchools(self): """Searches for schools using the configuration given previously the school IDs are stored as a class varaibles for later use """ urlBase = "http://www.education.gov.uk" urlPath = "/cgi-bin/schools/performance/search.pl?" params = ( ("searchType", "postcode"), ("postcode", self.postcode), ("distance", self.distance), ("phase", "all") ) urlParams = urllib.parse.urlencode(params) url = urlBase+urlPath+urlParams pageContent = getPage(url) self.setSchools(pageContent)