def CreateChickenPlace(self, id, place_info): ctx = ndb.get_context() menu_page = yield ctx.urlfetch(HOST + place_info["identifier"]) if not menu_page.status_code == 200: raise ndb.Return(None) parser = BeautifulSoup.BeautifulSoup(menu_page.content) address_1 = parser.find( id="ctl00_ContentPlaceHolder1_RestInfo_lblRestAddress").text address_2 = parser.find( id="ctl00_ContentPlaceHolder1_RestInfo_lblRestZip").text address = "%s, %s" % (address_1, " ".join(address_2.split())) place = ChickenPlace() place.key = ndb.Key(ChickenPlace, id, namespace=self.NAME) place.has_chicken = False # Check if they actually serve chicken: for tag in parser.findAll("h2", attrs={"class": "H2MC"}): if "chicken" in tag.text.lower(): place.has_chicken = True if place.has_chicken: # If they don't serve chicken then don't save any of their info. F**k them. place.identifier = place_info["identifier"] place.title = place_info["title"] place.address = address raise ndb.Return(place)
def CreateChickenPlace(self, id, place_info): ctx = ndb.get_context() menu_page = yield ctx.urlfetch(HOST + place_info["identifier"]) if not menu_page.status_code == 200: raise ndb.Return(None) parser = BeautifulSoup.BeautifulSoup(menu_page.content) address_1 = parser.find(id="ctl00_ContentPlaceHolder1_RestInfo_lblRestAddress").text address_2 = parser.find(id="ctl00_ContentPlaceHolder1_RestInfo_lblRestZip").text address = "%s, %s"%(address_1, " ".join(address_2.split())) place = ChickenPlace() place.key = ndb.Key(ChickenPlace, id, namespace=self.NAME) place.has_chicken = False # Check if they actually serve chicken: for tag in parser.findAll("h2", attrs={"class":"H2MC"}): if "chicken" in tag.text.lower(): place.has_chicken = True if place.has_chicken: # If they don't serve chicken then don't save any of their info. F**k them. place.identifier = place_info["identifier"] place.title = place_info["title"] place.address = address raise ndb.Return(place)