Ejemplo n.º 1
0
    def parse_tip(self, place, tip):
        tipId = tip['id']
        text = tip['text']
        createdAt = datetime.fromtimestamp(int(
            tip['createdAt'])).strftime('%Y-%m-%d %H:%M:%S')

        user = tip['user']
        userId = user['id']
        firstName = user['firstName']
        lastName = user['lastName']
        name = "%s %s" % (firstName, lastName)
        photo = user['photo']
        profilePicture = photo['prefix'] + 'original' + photo['suffix']

        utils = Utils()
        person = utils.get_user(userId, name, profilePicture)
        tip = utils.save_tip(tid=tipId,
                             author=person,
                             place=place,
                             text=text,
                             dateOfCreation=createdAt)

        print('\t\t[+] Tip Id: %s' % tipId)
        print('\t\t[+] Created at: %s' % createdAt)
        print('\t\t[+] User ID: %s' % userId)
        print('\t\t[+] Full Name: %s' % name)
        print('\t\t[+] Profile Picture: %s' % profilePicture)
        print('\t\t[+] Text: %s' % text)
        print('')
Ejemplo n.º 2
0
    def parse_venue(self, venue):
        venueId = venue['id']
        name = venue['name']
        checkinsCount = venue['stats']['checkinsCount']

        print('[*] Venue: %s' % name)
        print('\t[+] Checkins Count: %s' % checkinsCount)
        print('\t[+] Venue ID: %s' % venueId)

        utils = Utils()
        place = utils.get_place(pid=venueId, name=name, checkins=checkinsCount)
        #place.tip_set.count()

        self.get_tips(place)
        #self.get_photos(venueId)

        print('')
Ejemplo n.º 3
0
    def parsePhoto(self, photo, latitude, longitude):
        title = photo['title']
        farm = photo['farm']
        server = photo['server']
        photo_id = photo['id']
        secret = photo['secret']
        owner = photo['owner']
        url = "https://farm%s.staticflickr.com/%s/%s_%s_n.jpg" % (
            farm, server, photo_id, secret)

        print('[+] Photo ID: %s' % photo_id)
        print('\t[*] URL: %s' % url)
        print('\t[*] Title: %s' % title)

        (user, name, profile_picture) = self.getPerson(owner)
        utils = Utils()
        person = utils.get_user(user, name, profile_picture)

        (created_time, tags) = self.getPhotoInfo(photo_id)
        p = utils.save_post(photo_id, person, created_time, url, title,
                            latitude, longitude, "Flickr")
        utils.save_tags(tags, p)
        print('')
Ejemplo n.º 4
0
    def parsePost(self, post):
        if post["geo"]:
            pid = post["id"]
            user = post["user"]["screen_name"]
            name = post["user"]["name"]
            text = post["text"].encode('ascii', 'replace')
            latitude = post["geo"]["coordinates"][0]
            longitude = post["geo"]["coordinates"][1]
            profile_picture = post["user"]["profile_image_url_https"]
            created_time = time.strftime(
                '%Y-%m-%d %H:%M:%S',
                time.strptime(post["created_at"],
                              '%a %b %d %H:%M:%S +0000 %Y'))
            photo = ""

            tags = []
            for tag in post["entities"]["hashtags"]:
                tags.append(tag["text"])

            print('[+] Tweet ID: %s' % pid)
            print('\t[+] User: %s' % user)
            print('\t[+] Full Name: %s' % name)
            print('\t[+] Date of Creation: %s' % created_time)
            print('\t[+] Latitude: %s' % latitude)
            print('\t[+] Longitude: %s' % longitude)
            print('\t[+] Hashtags: %s' % tags)
            print('\t[+] Text: %s' % text)
            print('')

            utils = Utils()
            person = utils.get_user(user, name, profile_picture)
            p = utils.save_post(pid, person, created_time, photo, text,
                                latitude, longitude, "Twitter")
            utils.save_tags(tags, p)

            return pid