def badges(self): """ totalReviewBadge contains title and counts helpfulVotes contains the number of helpful votes """ try: totalReviewBadge = self.reviewer_tag.find('div', class_='totalReviewBadge') try: reviewerTitle = str(totalReviewBadge.find('div', class_='reviewerTitle').string) except AttributeError: reviewerTitle = '' counts = totalReviewBadge.find_all('span', class_='badgeText') try: review_count = TAutil.strip_comma(counts[0].string) except (AttributeError, IndexError): review_count = -1 try: hotel_review_count = TAutil.strip_comma(counts[1].string) except (AttributeError, IndexError): hotel_review_count = -1 except AttributeError: reviewerTitle = '' review_count = -1 hotel_review_count = -1 try: helpfulVotes = str(self.reviewer_tag.select('div.helpfulVotesBadge span.badgeText')[0].string) helpful_count = TAutil.strip_comma(helpfulVotes) except (AttributeError, IndexError): helpful_count = -1 return reviewerTitle, review_count, hotel_review_count, helpful_count
def large_reviews(self, hotel): try: temp_str = str(hotel.find('span', class_='more').a.string).strip() number_reviews = TAutil.strip_comma(temp_str) except AttributeError as e: return False if number_reviews < self.min_reviews: return False else: return True
def trip_type(self): trip_type_s = self.soup.select('div.trip_type div.value') trip_type = [TAutil.strip_comma(x.string) for x in trip_type_s] if not trip_type: trip_type = [-1]*4 return trip_type
def rating_count(self): rating_number_s = self.soup.select('div.col2of2.composite span.compositeCount') rating_number = [TAutil.strip_comma(x.string) for x in rating_number_s] return rating_number
def numHlp(self): try: return TAutil.strip_comma(self.reviewer_tag.find('span', class_='numHlpIn').string) except AttributeError: return 0