Getting started:
Related tutorials:
| #!/usr/bin/env python | |
| import simplejson | |
| import urllib2 | |
| from pprint import pprint | |
| req = urllib2.Request('https://api.twitter.com/1/trends/1.json') | |
| opener = urllib2.build_opener() | |
| f = opener.open(req) |
| consumer_key = 'your-consumer-key' | |
| consumer_secret = 'your-consumer-secret' | |
| access_token = 'your-access-token' | |
| access_secret = 'your-access-secret' |
| from __future__ import with_statement # we'll use this later, has to be here | |
| from argparse import ArgumentParser | |
| import requests | |
| from BeautifulSoup import BeautifulStoneSoup as Soup | |
| def parse_sitemap(url): | |
| resp = requests.get(url) | |
| # we didn't get a valid response, bail |
| import requests | |
| from bs4 import BeautifulSoup | |
| import pandas as pd | |
| from datetime import datetime | |
| from tqdm import tqdm | |
| from functools import reduce | |
| def getSources(): | |
| source_url = 'https://newsapi.org/v1/sources?language=en' | |
| response = requests.get(source_url).json() |
| #!/usr/bin/env python | |
| # encoding: utf-8 | |
| """ | |
| twitrend.py | |
| """ | |
| import sys | |
| import os | |
| import tweepy |
| import requests | |
| import urllib | |
| import json | |
| import base64 | |
| class TrendGetter(): | |
| @staticmethod | |
| def get_trending_hashtags(): |
| # -*- coding: utf-8 -*- | |
| from random import randint | |
| import twitter | |
| import time | |
| api = twitter.Api(consumer_key='...', | |
| consumer_secret='...', | |
| access_token_key='...', | |
| access_token_secret='...') |
| [github] | |
| login= | |
| password= | |
| [twitter] | |
| CONSUMER_KEY= | |
| CONSUMER_SECRET= | |
| ACCESS_TOKEN= | |
| ACCESS_TOKEN_SECRET= |
| from lxml import etree | |
| root = etree.fromstring(xml_str) | |
| def xml2json(self, root): | |
| children = root.findall('ResponseData/ResponseDataObject')[0] | |
| def recusiv(children): | |
| out = {} | |
| for child in list(children): | |
| if len(list(child)): |
Getting started:
Related tutorials: