def GetSingleEvent(self, eventLandingPage): eventLandingPage = self.urlify(eventLandingPage) self.page = requests.get(eventLandingPage) eventTree = html.fromstring(self.page.text) new_event = Event() new_event.source = eventLandingPage.encode('utf-8') new_event.name = self.multipleXPaths(self.eventName_xpath, eventTree, 'name') new_event.location += self.multipleXPaths(self.eventLocation_xpath, eventTree, 'location') new_event.description = self.multipleXPaths(self.eventDescription_xpath, eventTree, 'description') new_event.datetime = self.multipleXPaths(self.eventDateTime_xpath, eventTree, 'datetime') new_event.price = self.multipleXPaths(self.eventPrice_xpath, eventTree, 'price') new_event.imagePath = self.multipleXPaths(self.eventImage_xpath, eventTree, 'imagePath') new_event.imagePath = self.urlify(new_event.imagePath) new_event.dump = SiteText(eventLandingPage).gettext() new_event.cleanContent() # print (new_event) # print (new_event.name), " name" # print (new_event.location), " location" # print (new_event.description), " description" # print (new_event.datetime), " datetime" # print (new_event.price), " price" # print (new_event.imagePath), " imagePath" return new_event
def parseOneJson(self, obj): count = 0; if ((obj[self.eventResults] is not None) and (len(obj[self.eventResults])>0)): for result in obj[self.eventResults]: count += 1 sys.stdout.write("\rGetting " + str(count) + " of " + str(len(obj[self.eventResults]))) sys.stdout.flush() event = Event() event.name = self.checkIfList(self.eventName, result) event.location = self.checkIfList(self.location, result) event.description = self.checkIfList(self.description, result) event.datetime = self.checkIfList(self.eventTime, result) event.price = self.checkIfList(self.price, result) event.imagePath = self.checkIfList(self.image, result) event.dump = self.checkIfList(self.description, result) event.forceStr() self.allEvents.append(event) print "\n" return True else: return False