예제 #1
0
파일: agent.py 프로젝트: mishudark/Hotot
def crack_token(params):
    if params[1] == 'load':
        token = config.load_token()
        push_option('lib.twitterapi', 'access_token', json.dumps(token))
    elif params[1] == 'dump':
        config.dump_token(json.loads(urllib.unquote(params[2])))
    pass
예제 #2
0
파일: agent.py 프로젝트: mishudark/Hotot
def apply_config():
    version = 'ver %s (%s)'% (hotot.__version__, hotot.__codename__)
    default_username = config.default_username
    default_password = config.default_password
    access_token = json.dumps(config.load_token())
    exts_enabled = json.dumps(config.exts_enabled)
    webv.execute_script('''
        $('#version').text('%s');
        $('#tbox_basic_auth_username').attr('value', '%s');
        $('#tbox_basic_auth_password').attr('value', '%s');
        jsOAuth.access_token = %s;
        ext.exts_enabled = %s;
        ''' % (version
            , default_username, default_password
            , access_token
            , exts_enabled))
    apply_prefs()
    pass
예제 #3
0
#!/usr/bin/python3

import datetime
import config, people, twitter_api

token = config.load_token('/vagrant/token/twitter.json')

users = people.load('./people.json.pretty')

today = datetime.date.today()

i = 0
for user_id, user in users.items():
    i += 1
    print(i)

    u = twitter_api.user(token, user_id)
    if u is None:
        continue

    if 'since_id' not in user['twitter']:
        user['twitter']['since_id'] = -1
    since_id = user['twitter']['since_id']

    ids = twitter_api.user_tweets_id(token, user_id, since_id)

    if '_activity' not in user['twitter']:
        user['twitter']['_activity'] = {}

    activity = {
        'statuses_count': u['statuses_count'],
예제 #4
0
#!/usr/bin/python

import config
token = config.load_token('/vagrant/config/foursquare.json')

from api_foursquare import category_hierarchy
categories = category_hierarchy(token)

import json
with open('/vagrant/data/osn-data/category_hierarchy.json', 'w') as file:
    json.dump(categories, file, sort_keys=True)
예제 #5
0
import requests

from config import load_token
from model.scraper.util import generate_url_query, get_json_response

TOKEN = load_token()

FACEBOOK_GRAPH_BASE_URL = "https://graph.facebook.com/v2.11/"
BRUINFEED = "163576114113950"


class FeedScraper:
    def __init__(self, feed_id: str, limit: int):
        self.feed_id = feed_id
        self.limit = limit

    def get_id_posts(self):
        feed_response = requests.get(
            generate_url_query(self.feed_id + "/feed?limit=" +
                               str(self.limit)))
        json_posts = get_json_response(feed_response)
        return [json_post['id'] for json_post in json_posts['data']]
예제 #6
0
#!/usr/bin/python3

import datetime, json, re

import config, people, tweets, tips
import history, history_foursquare, history_twitter
import foursquare_api, twitter_api

token = config.load_token('/vagrant/token/twitter.json')
token_foursquare = config.load_token('/vagrant/token/foursquare.json')

local_tweets = tweets.load('./tweets.json')

from_date = '2016-01-01'
to_date = '2016-12-31'

weekdays = {
    'Mon': '1_Mon',
    'Tue': '2_Tue',
    'Wed': '3_Wed',
    'Thu': '4_Thu',
    'Fri': '5_Fri',
    'Sat': '6_Sat',
    'Sun': '7_Sun'
}

months = {
    'Jan': '01',
    'Feb': '02',
    'Mar': '03',
    'Apr': '04',
예제 #7
0
#!/usr/bin/python3

import datetime
import config, people, instagram_api
import json

token = config.load_token('/vagrant/token/instagram.json')

users = people.load('./people.json.pretty')

today = datetime.date.today()

i = 0
for user_id, user in users.items():
  i += 1
  if i > 4:
    break
  print(i)
  instagram = user['instagram']
  if 'id' not in instagram:
    continue
  user_id = instagram['id']
  if user_id is None:
    continue
  print(user_id)
  user_media = instagram_api.user_media(token, user_id)
  if user_media is not None:
    if '_activity' not in instagram:
      instagram['_activity'] = {}
#    activity = {'statuses_count':remote_user['statuses_count'],'favourites_count':remote_user['favourites_count'],'friends_count':remote_user['friends_count'],'followers_count':remote_user['followers_count'],'listed_count':remote_user['listed_count']}
    instagram['_activity'][str(today)] = activity