h.geometry=[float(mapcontainer[0].get('data-lng')),float(mapcontainer[0].get('data-lat'))]
        else:
            try:
                geolocator = GoogleGeocoder()
                geolocation=None
                for coords in geolocator.get(h.address):
                    if(geo.checkCoordinate(coords.geometry.location.lng,coords.geometry.location.lat)):
                        geolocation =coords
                print("Google")
                print(geolocation.geometry.location.lng)
                h.geometry=[geolocation.geometry.location.lng,geolocation.geometry.location.lat]
            except Exception:
                print(h.address+"Address cannot be located")
        print(h.geometry)
        h.save()
    for review, rating, user, quote in zip(adjreviews, ratings, users, quotes):
        r = HotelReview()
        r.review = str(review.text)
        #r.rating = int(str(rating)[2])
        r.rating = int(rating.get("alt")[0:rating.get("alt").index(" ")])
        r.reviewLocation =h
        r.title = str(quote.text)
        u=addUser(str(user)[2:-1])
        r.user=u
        print("User recorded on review: "+u.name)
        r.save()


print(len(links))

disconnect()
コード例 #2
0
                geolocator = GoogleGeocoder()
                geolocation = None
                for coords in geolocator.get(h.address):
                    if (geo.checkCoordinate(coords.geometry.location.lng,
                                            coords.geometry.location.lat)):
                        geolocation = coords
                print("Google")
                print(geolocation.geometry.location.lng)
                h.geometry = [
                    geolocation.geometry.location.lng,
                    geolocation.geometry.location.lat
                ]
            except Exception:
                print(h.address + "Address cannot be located")
        print(h.geometry)
        h.save()
    for review, rating, user, quote in zip(adjreviews, ratings, users, quotes):
        r = HotelReview()
        r.review = str(review.text)
        #r.rating = int(str(rating)[2])
        r.rating = int(rating.get("alt")[0:rating.get("alt").index(" ")])
        r.reviewLocation = h
        r.title = str(quote.text)
        u = addUser(str(user)[2:-1])
        r.user = u
        print("User recorded on review: " + u.name)
        r.save()

print(len(links))

disconnect()
            prop.activity.append(str(activities)[3:-2])
        prop.url='http://www.tripadvisor.com'+link
        prop.type= []
        if("," in str(types[0].text)):
            prop.type= [t for t in str(types[0].text).split(",")]
        else:
            prop.type.append(str(types[0].text))
        updated = Attraction.objects(attractionID=int(a.attractionID)).update_one(set__properties=prop)
        if not updated:
            Attraction.objects.update_one(push__properties=prop)
    #print(len(zip(reviews, ratings, users)))
    for review, rating, user, quote in zip(reviews, ratings, users, quotes):
        print("try")
        r = Review()
        r.review = str(review.text)
        try:
            r.rating = float(rating.get("alt")[0:rating.get("alt").index(" ")])
        except Exception:
            r.rating = None
        r.reviewLocation=a
        r.title = str(quote.text)
        u=addUser(user.text)
        r.user=u
        print("User recorded on review: "+u.name)
        r.save()



print(len(links))

disconnect()
        else:
            prop.activity.append(str(activities)[3:-2])
        prop.url = 'http://www.tripadvisor.com' + link
        prop.type = []
        if ("," in str(types[0].text)):
            prop.type = [t for t in str(types[0].text).split(",")]
        else:
            prop.type.append(str(types[0].text))
        updated = Attraction.objects(
            attractionID=int(a.attractionID)).update_one(set__properties=prop)
        if not updated:
            Attraction.objects.update_one(push__properties=prop)
    #print(len(zip(reviews, ratings, users)))
    for review, rating, user, quote in zip(reviews, ratings, users, quotes):
        print("try")
        r = Review()
        r.review = str(review.text)
        try:
            r.rating = float(rating.get("alt")[0:rating.get("alt").index(" ")])
        except Exception:
            r.rating = None
        r.reviewLocation = a
        r.title = str(quote.text)
        u = addUser(user.text)
        r.user = u
        print("User recorded on review: " + u.name)
        r.save()

print(len(links))

disconnect()