<jupyter_start><jupyter_text>Project 1 Api Based Data Scrap Site url : http://www.omdbapi.com/ import library<jupyter_code>from urllib.request import urlopen
import json<jupyter_output><empty_output><jupyter_text>define api key and movie name<jupyter_code>api_key = 'f41c7e6d'
movie_names = ['Joker', 'WALL-E', 'Psycho']<jupyter_output><empty_output><jupyter_text>create data list<jupyter_code>movies_title = []
released = []
internet_movie_database = []
rotten_tomatoes = []<jupyter_output><empty_output><jupyter_text>data scrap<jupyter_code>for i in range(len(movie_names)):
    url = 'http://www.omdbapi.com/?t={}&apikey={}'.format(movie_names[i], api_key)
    response = urlopen(url)
    data = response.read()
    decode_data = data.decode()
    json_data = json.loads(decode_data)
    #print(json_data)
    movies_title.append(json_data['Title'])
    released.append(json_data['Released'])
    internet_movie_database.append(json_data['Ratings'][0]['Value'])
    rotten_tomatoes.append(json_data['Ratings'][1]['Value'])<jupyter_output><empty_output><jupyter_text>print movie list<jupyter_code>print(movies_title)
print(released)
print(internet_movie_database)
print(rotten_tomatoes)<jupyter_output>['Joker', 'WALL·E', 'Psycho']
['04 Oct 2019', '27 Jun 2008', '08 Sep 1960']
['8.9/10', '8.4/10', '8.5/10']
['68%', '95%', '96%']<jupyter_text>create csv file<jupyter_code>file_name = 'my_movies.csv'
with open(file_name, 'w') as fobj:
    fobj.write('Title' + ',' + 'Released' + ',' + 'Internet Movie Database Rating' + ',' + 'Rotten Tomatoes Rating' + '\n')
    for j in range(len(movies_title)):
        fobj.write(movies_title[j] + ',' + released[j] + ',' + internet_movie_database[j] + ',' + rotten_tomatoes[j] + '\n')
print(file_name, 'Created Successfully!')<jupyter_output>my_movies.csv Created Successfully!
{'fraction_non_alphanumeric': 0.1694169416941694, 'fraction_numerical': 0.023652365236523653, 'mean_word_length': 6.908695652173913, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '289991', 'license': 'MIT', 'n_tokens_mistral': 730, 'n_tokens_neox': 694, 'n_words': 106, 'path': 'Api Based Data Scrap/project_1_get_movie_list_omdbi.ipynb', 'repo_name': 'sajib1066/web-crawler-projects', 'size': '1818'}