This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tweepy | |
consumer_key = 'XXXX' | |
consumer_secret = 'XXXX' | |
access_key = 'XXXX-XXXX' | |
access_secret = 'XXXX' | |
auth = tweepy.OAuthHandler(consumer_key, consumer_secret) | |
auth.set_access_token(access_key, access_secret) | |
api = tweepy.API(auth) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from string import digits, ascii_uppercase | |
from random import choice | |
c = 0 | |
while 1: | |
c += 1 | |
with open(str(c), 'w+') as f: | |
f.write(''.join(choice('ascii_uppercase + digits') for x in range(999999))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from nltk.tokenize import word_tokenize | |
from nltk.corpus import stopwords | |
from collections import OrderedDict | |
import string | |
import praw | |
import re | |
import matplotlib.pyplot as plt | |
client_id = 'XXXX' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from InstagramAPI import InstagramAPI | |
from random import randint | |
from time import sleep | |
import requests | |
import json | |
class Colour: | |
Green, Red, White, Yellow = '\033[92m', '\033[91m', '\033[0m', '\033[93m' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from bs4 import BeautifulSoup | |
import requests | |
# reusable main soup function | |
def lovely_soup(url): # passes the url as a variable | |
r = requests.get(url) # get the requested url | |
soup = BeautifulSoup(r.text, 'lxml') # turn html content into soup | |
return soup | |
# soup helper function |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[{ | |
"quoteText": "Genius is one percent inspiration and ninety-nine percent perspiration.", | |
"quoteAuthor": "Thomas Edison" | |
}, { | |
"quoteText": "You can observe a lot just by watching.", | |
"quoteAuthor": "Yogi Berra" | |
}, { | |
"quoteText": "A house divided against itself cannot stand.", | |
"quoteAuthor": "Abraham Lincoln" | |
}, { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
from collections import Counter | |
data = open('test.txt', 'r', encoding='utf-8').read() | |
words = re.findall('\w+', data.lower()) | |
counted = Counter(words) | |
common = counted.most_common() | |
for word, score in common: | |
print(word, score) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from bs4 import BeautifulSoup | |
import requests | |
def lovely_soup(url): | |
r = requests.get(url) | |
html_content = r.text | |
soup = BeautifulSoup(html_content, 'lxml') | |
return soup |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create a directory called comics next to the script first | |
import requests | |
n = 933 | |
while True: | |
if n == 404: | |
n += 1 | |
url = 'https://xkcd.com/{}/info.0.json'.format(n) | |
r = requests.get(url) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
import tweepy | |
import json | |
import sys | |
import praw | |
from halo import Halo | |
consumer_key = 'XXXX' | |
consumer_secret = 'XXXX' | |
access_key = 'XXXX-XXXX' |