HOW WE FEEL ABOUT JOKER

Scraping IMDB for JOKER reviews

Outputs txt files for corpus creation!!

In [1]:
import re
import urllib
from bs4 import BeautifulSoup
In [2]:
def get_reviews(rating):
    url = "https://www.imdb.com/title/tt7286456/reviews?sort=helpfulnessScore&dir=desc&ratingFilter=" + str(rating)
    html = urllib.request.urlopen(url).read()
    soup = BeautifulSoup(html, 'html.parser')
    text = soup.findAll("div", {"class": "imdb-user-review"})
    for num,t in enumerate(text):
        scale = t.find("span", {"class": "point-scale"})
        title = t.find("a", {"class": "title"})
        text = t.find("div", {"class": "text show-more__control"})
#         review = title.text + "==" + text.text
        review = title.text + text.text
        try:
            print_to_file(scale.previous_sibling.text, review, num)
        except:
            print('nope')

def print_to_file(rating, review, num):
#     both = rating + '**' + review
    both = review
    output_filename = str(rating) + '_jk_v2_' + str(num) + '.txt'
    outfile = open(output_filename, 'w')
    outfile.write(both)
    outfile.close()
        
for rating in range(1,11):
    get_reviews(rating)
nope
nope
nope
nope
In [ ]: