Esempio n. 1
0
def find_news():
    fb = Facebook(license='CAAEuAis8fUgBAAZB8tJX5T9qPXpFolTmCpFQNMZBHoHuGpwuhjHYUwyIHR2Xm9lENwbewkSwM0NS3sZBXJGFcOUeiwUYBKxWqtbDnfxMzmAOfI0s48bjXjKKYZB2eSvnZBMLA0iz1HeZCMHPFNxgaqhEufsZAzQuwT4bqQ77YFz426lH1YEZCJcJ', throttle=1.0, language='en')
    person = fb.profile(id=find_id())
    postkey=()    
    posts=[]    
    
    for post in fb.search(person['id'], type=NEWS, count=pullnum):
        if find_name() not in post.text: 
            popularity = post.comments + post.likes             
            postkey = (popularity, post.text)
            posts.append(postkey)
    return posts
Esempio n. 2
0
def fetch_data(data="facebook.pickle",
               friends_count=1000,
               news_count=100,
               key='REMOVED MY KEY'):
    """ Fetches link data from given key for the specified number 
		of friends and the specified number of posts and saves it
		to a facebook.pickle file

		data: name of data file to save to (default: facebook.pickle)
		friends_count: number of friends to search through (default: 1000)
		news_count: number of each friends' posts to search through (default: 100)
		key: the key for pattern to access Facebook
	"""
    print "Fetching data..."

    # Get the data
    fb = Facebook(license=key)
    me = fb.profile()
    print me
    counter = 1

    link_counts = {"num_posts": 0, "num_links": 0, "num_texts": 0}

    my_friends = fb.search(me[0], type=FRIENDS, count=friends_count)
    for friend in my_friends:
        print counter
        counter += 1
        friend_news = fb.search(friend.id, type=NEWS, count=news_count)
        for news in friend_news:
            link_counts["num_posts"] += 1
            if news.url:
                link_counts["num_links"] += 1
                if news.url in link_counts:
                    link_counts[news.url][0] += 1
                    link_counts[news.url][1] += news.likes
                else:
                    link_counts[news.url] = [1, news.likes]

    # Save the data to a file
    f = open(data, 'w')
    cPickle.dump(link_counts, f)
    f.close()
Esempio n. 3
0
# Create a .csv in pattern/examples/01-web/
table.save(pd("opinions.csv"))

# 2) Status updates from specific profiles.
#    For this you need a personal license key:
#    http://www.clips.ua.ac.be/pattern-facebook

license = ""

if license != "":
    fb = Facebook(license)
    # Facebook.profile() returns a dictionary with author info.
    # By default, this is your own profile.
    # You can also supply the id of another profile,
    # or the name of a product page.
    me = fb.profile()["id"]
    for status in fb.search(me, type=NEWS, count=30, cached=False):
        print("-" * 100)
        print(status.id)    # Status update unique id.
        # Status title (i.e., the id of the page or event given as URL).
        print(status.title)
        print(status.text)  # Status update text.
        print(status.url)   # Status update image, external link, ...
        if status.comments > 0:
            # Retrieve comments on the status update.
            print("%s comments:" % status.comments)
            print([(x.author, x.text, x.likes)
                   for x in fb.search(status.id, type=COMMENTS)])
        if status.likes > 0:
            # Retrieve likes on the status update.
            print("%s likes:" % status.likes)
Esempio n. 4
0
# Create a .csv in pattern/examples/01-web/
table.save(pd("opinions.csv"))

# 2) Status updates from specific profiles.
#    For this you need a personal license key:
#    http://www.clips.ua.ac.be/pattern-facebook

license = ""

if license != "":
    fb = Facebook(license)
    # Facebook.profile() returns an (id, name, date of birth, gender, locale, likes)-tuple.
    # By default, this is your own profile.
    # You can also supply the id of another profile,
    # or the name of a product page.
    me = fb.profile()[0]
    for status in fb.search(me, type=NEWS, count=30, cached=False):
        print "-" * 100
        print status.id  # Status update unique id.
        print status.title  # Status title (i.e., the id of the page or event given as URL).
        print status.text  # Status update text.
        print status.url  # Status update image, external link, ...
        if status.comments > 0:
            # Retrieve comments on the status update.
            print "%s comments:" % status.comments
            print[(x.author, x.text, x.likes)
                  for x in fb.search(status.id, type=COMMENTS)]
        if status.likes > 0:
            # Retrieve likes on the status update.
            print "%s likes:" % status.likes
            print[x.author for x in fb.search(status.id, type=LIKES)]
Esempio n. 5
0
# -*- coding: utf-8 -*-
"""
Created on Mon Sep 27 20:13:30 2014

@author: gianfranco
"""

from pattern.web import Facebook, NEWS, COMMENTS, LIKES

fb = Facebook(license='CAAEuAis8fUgBAIjddb5eck615kBpLhvmwaO9dh1ZBIv6YfsPGu0MhzdILYwAQX90qsmLTZCCeZCrwc0U07mzpE1grLUPAXfxyp6lbZCOD1xz1pzlplGbgM0gKWTKhR4nBYkwdJR9CZB0VDdS0f99IopQ7Uv6VZCyZAhMJnKz1yloCpwM4WNHoAG')
me = fb.profile(id=None) # user info dict
#This part of the code search for the last person that post in my wall that is not me
for post in fb.search(me['id'], type=NEWS, count=1000):
    if post.author[0]!=me['id']:
        amigo_id=post.author[0]
        break
#This part, is similar that the first part but in the friend wall that write my last post
for post in fb.search(amigo_id, type=NEWS, count=1000):
    if post.author[0]!=amigo_id:
        amigo1_id=post.author[0]
        break
#no that is defined the Facebook ID I will use google shortener URL API
#to give the link of the friend of my friend.


import requests
import urllib, urllib2
import json


def goo_shorten_url(url):
Esempio n. 6
0
from pattern.web import Facebook, NEWS, COMMENTS, LIKES

fb = Facebook(license='CAACEdEose0cBAD0FqhYX26Tg9h7062f5KxELjcZC6mt91UeyRYNeUJb8WZA\
	eJZCELWSCqqeTL7SkwbVkgyV3PxVXCnNoa0o6ywdNtSa0AmW8n7oifV5l5ImQZBBXSWD9lEE8o4pggBz\
	p9NLV5x4vqcwdyW2xZB9CcHCylZBqURoQqrwZBcpTdZATZCs5BkX0WP964JdWoO7quMg40HImUv6WA')

me = fb.profile(id='10203550007847585') 

def get_posts():
	for post in fb.search(me[0], type=NEWS, count=10):
		print 'post :'+ repr(post.text) +' likes :'+ repr(post.likes)

#Navegue, acceda al chat, mire videos, revise sus correos y redes sociales desde su celular. 
#Recargue el saldo de su telefono y adquiera el Paquete de Internet en cualquier momento y lugar. Solo tiene que enviar un mensaje de texto al 779 con la palabra clave indicada en el siguiente recuadro:
#200 MB	5D
#700 MB	10D
Esempio n. 7
0
from pattern.web import Facebook, NEWS, COMMENTS, LIKES, FRIENDS

fb = Facebook(license='CAAEuAis8fUgBAGvbgzlR88GbrThcUGshnz9njXesze8zWbc6ha9heTCKuHNE3KmGdrZCpTitFpFQwlIA5DN9b1kfYtueew9d5N74EKGfGjqGu8E8Ux2168sfjrsJ3QFi9pNG5DL4yBvWrEEmF9aOoTCIWfW8tCpyT9LXPKK61pkH4E5R0D')
me = fb.profile(id=None) # (id, name, date, gender, locale, likes)-tuple
count=0
for post in fb.search(100000008147254, type=NEWS, count=1000):
    count+=1
    print post.description
    print repr(post.id)
    print repr(post.date)
    print repr(post.text)
    print repr(post.url)
    if post.comments > 0:
        print '%i comments' % post.comments 
        print [(r.text, r.author) for r in fb.search(post.id, type=COMMENTS)]
    if post.likes > 0:
#        print post.text
        print '%i likes' % post.likes 
        print [r.author for r in fb.search(post.id, type=LIKES)]
Esempio n. 8
0
    if len(table) == 0 or id not in index:
        table.append([id, status.text])
        index[id] = True

table.save("negative.txt")

# 2) Status updates from profiles.

# You need a personal license key first:
# http://www.clips.ua.ac.be/media/pattern-fb.html
license = ""

if license != "":
    fb = Facebook(license)
    # Facebook.profile() returns an (id, name, date of birth, gender, locale)-tuple.
    # By default, this is your own profile. 
    # You can also supply the id of another profile.
    me = fb.profile()[0]
    for status in fb.search(me, type=NEWS, count=10, cached=False):
        print status.id   # Status update unique ID.
        print status.text # Status update text.
        print status.url  # Status update image, external link, ...
        if status.comments > 0:
            # Retrieve comments on the status update.
            print "%s comments:" % status.comments
            print [(x.text, x.author) for x in fb.search(status.id, type=COMMENTS)]
        if status.likes > 0:
            # Retrieve likes on the status update.
            print "%s likes:" % status.likes
            print [x.author for x in fb.search(status.id, type=LIKES)]
        print
# -*- coding: utf-8 -*-

"""
Pattern.web can be used to extract information from Wikipedia, Facebook, Twitter, etc
Find out more: https://www.clips.uantwerpen.be/pages/pattern-web
"""

from pattern.web import Facebook
from pattern.en import sentiment
from pattern.web import Facebook, NEWS, COMMENTS, LIKES

fb = Facebook(license='568752540312810')
me = fb.profile(id=568752540312810) # user info dict

for post in fb.search(me['id'], type=NEWS, count=100):
    print repr(post.id)
    print repr(post.text)
    print repr(post.url)
    if post.comments > 0:
        print '%i comments' % post.comments 
        print [(r.text, r.author) for r in fb.search(post.id, type=COMMENTS)]
    if post.likes > 0:
        print '%i likes' % post.likes 
        print [r.author for r in fb.search(post.id, type=LIKES)]
"""
facebook = Facebook()
someTweet = None
feeling = ""

for j in range(1):
    for post in facebook.search('Teressa May', start=someTweet, count=1):
Esempio n. 10
0
# -*- coding: utf-8 -*-
# Bonnie Ishiguro
"""
Created on Thu Feb 27 20:12:00 2014

@author: bishiguro
"""
from num_syllables import *
from pattern.web import Facebook, FRIENDS, NEWS
token = "CAAEuAis8fUgBAC3MHxZAMvEy9Q4uveZB9AVJc11AKo5sK4yJVIy0PitOYNZAhRBkCjXcvT2uaCgPuElZBMEeZBLcRtiopFh4bnraCPjC3iZBb8wfRG2cBLaiIVyuj4xH7ZBFZAjyWZCmZB3yEtY11uDJyvRlW12oKjkN286eYP4R6rYTgLT8v2MtdJlHrwq5AuAW8ZD"
fb = Facebook(license = token)
me = fb.profile(id=None)

def get_posts(name): 
    '''returns a list of a user's recent posts'''
    posts = []
    friend_name = ""
    friend_news = ""
    my_friends = fb.search(me[0],type=FRIENDS,count=1000)
    for friend in my_friends:
        if name == str(friend.author[1]):
            friend_name = str(friend.author[1])
            friend_news = fb.search(friend.id,type=NEWS,count=1000)
    if not(friend_name == ""):
        for news in friend_news:             
            if (news.author[1]) == friend_name:
                if not("friends" in str(news.text)) and not("likes" in str(news.text)) and not("event" in str(news.text)) and not("post" in str(news.text)) and not("photo" in str(news.text)) and not("link" in str(news.text)) and not("profile" in str(news.text)) and not("invited" in str(news.text)) and not("status" in str(news.text)) and not("timeline" in str(news.text)) and not("tagged" in str(news.text)) and not("changed" in str(news.text)):   
                    posts.append(str(news.text))
        return posts
    return ""
    
Esempio n. 11
0
"""
Created on Tue Sep 30 09:45:10 2014

@author: abigail
"""

import time # import package
start = time.time() #start keeps track of time

#import pickle

from pattern.web import Facebook, NEWS, LIKES, FRIENDS # import pattern from Facebook API

fb = Facebook(license='CAAEuAis8fUgBALDf0mJZAQrXiOCN01f3DmCoz9vtGmpgt7qYtMeIDwDRC9yPSxZBFg53HPLd9hVQuU6YmWvk0HDYIayKla2RTgIkk50dbsENw6n9KvLZCqwUWG2PrvCXy8fp2KHZCcKYUefAFO4CsTufwlWPmSzo1Pm9e5ywmWdRxaSBS5e5')
# put in my license key for Facebook
me = fb.profile() # takes information from my profile

my_friends = fb.search(me['id'], type=FRIENDS, count=100) #creates a list of my friends' ids
#print my_friends

result_ids = [friend.id.encode('utf-8') for friend in my_friends] #removed the u' from the ids
#print result_ids
word_counter = {} # created a word counter - initialized as an empty array
for friend in my_friends:
    news = fb.search(friend['id'], type=NEWS, count=100) # gets newsfeeds from all my friends
    for post in news:

        feed = post.text.lower() #made the entire newsfeed lowercase
#        print post.text.split()
#        print feed
        if post.likes > 0: #when the likes for posts is more than 0, print the post