Interview Question
Code: # Parse https://metacritic.com/game/playstation-4 import json import re from bs4 import BeautifulSoup; import requests; from flask import Flask; from flask import jsonify; # Webserver IP and port. host = "127.0.0.1" ; port = 5001 ; # Initialize Flask app app = Flask(__name__); url= "https://www.metacritic.com/game/playstation-4" ; #response = requests.get(url); #print (response); # If the response code is 403 then use user_agent = {'User-agent': 'Mozilla/5.0'} user_agent = { 'User-agent' : 'Mozilla/5.0' }; def webscrapper (): response = requests.get(url, headers = user_agent); #print(response); # This would return 200 # Parse the html file and save the objects #print(response.text); soup = BeautifulSoup(response.text, 'html.parser' ); #print (soup); # Create a dictionary to save the title and score. title = []; score = []; for i in soup.findAll( 'a' ,{ "class" :...