Exemplo n.º 1
0
def get_facebook_shares(url):
    try:
        fb_data = reqSession.get('https://graph.facebook.com/?ids='+url).json()
        return fb_data[url]['shares']
    except:
        fb_data = reqSession.get('https://graph.facebook.com/'+url).json()
        if 'shares' in fb_data:
            return fb_data['shares']
        return 0
Exemplo n.º 2
0
def get_facebook_shares(url):
    try:
        fb_data = reqSession.get('https://graph.facebook.com/?ids=' +
                                 url).json()
        return fb_data[url]['shares']
    except:
        fb_data = reqSession.get('https://graph.facebook.com/' + url).json()
        if 'shares' in fb_data:
            return fb_data['shares']
        return 0
Exemplo n.º 3
0
def get_reddit_upvotes(url):
    reddit_url = get_reddit_data_url(url)
    try:
        reddit_data = reqSession.get(reddit_url).json()
        return reddit_data[0]['data']['children'][0]['data']['ups']
    except:
        return 0
Exemplo n.º 4
0
def get_reddit_upvotes(url):
    reddit_url = get_reddit_data_url(url)
    try:
        reddit_data = reqSession.get(reddit_url).json()
        return reddit_data[0]['data']['children'][0]['data']['ups']
    except:
        return 0
Exemplo n.º 5
0
def get_twitter_retweets(url):
    try:
        twitter_data = reqSession.get('http://urls.api.twitter.com/1/urls/count.json?url='+url).json()
    except Exception as e:
        logger.error('Unable to get retweets for url: %s. Exception: %s, %s',
                     url, e.__class__.__name__, e.message)
        return 0
    if 'count' in twitter_data:
        return twitter_data['count']
    return 0
Exemplo n.º 6
0
def get_twitter_retweets(url):
    try:
        twitter_data = reqSession.get(
            'http://urls.api.twitter.com/1/urls/count.json?url=' + url).json()
    except Exception as e:
        logger.error('Unable to get retweets for url: %s. Exception: %s, %s',
                     url, e.__class__.__name__, e.message)
        return 0
    if 'count' in twitter_data:
        return twitter_data['count']
    return 0
Exemplo n.º 7
0
 def __init__(self, raw_url, feed):
     self.raw_url = raw_url
     self.feed = feed
     self.page_req = reqSession.get(raw_url)
     self.soup = BeautifulSoup(self.page_req.text, 'html5lib')
     self.url = get_url(self.page_req, self.soup)
     self.content_text = extract_article(self.page_req.text)
     self.title = get_title(self.soup, self.feed)
     self.description = get_description(self.soup, self.feed)
     self.timestamp = get_timestamp(self.feed)
     self.image_url = get_image_url(self.soup, self.url)
     self.icon_url = get_icon_url(self.soup, self.url)
     self.type = get_type(self.url, self.soup)
     self.raw_html = self.page_req.text
Exemplo n.º 8
0
def get_reddit_data_url(url):
    reddit_redirect_req = reqSession.get('http://www.reddit.com/'+url)
    reddit_url = reddit_redirect_req.url
    if reddit_url[-1] != '/':
        reddit_url += '/'
    return reddit_url +'.json'
Exemplo n.º 9
0
def get_reddit_data_url(url):
    reddit_redirect_req = reqSession.get('http://www.reddit.com/' + url)
    reddit_url = reddit_redirect_req.url
    if reddit_url[-1] != '/':
        reddit_url += '/'
    return reddit_url + '.json'