Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests
- import json
- from bs4 import BeautifulSoup
- def check_valid():
- url = input("Input the URL:")
- r = requests.get(url)
- if r:
- try:
- print(r.json()['content'])
- except Exception:
- print("Invalid quote resource!")
- # check_valid()
- def check_movie():
- r = requests.get(input(), headers={'Accept-Language': 'en-US,en;q=0.5'})
- if r:
- try:
- soup = BeautifulSoup(r.content, 'html.parser')
- #title = soup.find('h1', class_='long').get_text()
- title = soup.find('div', class_='originalTitle').get_text()
- #description = soup.find('div', class_='ipc-html-content ipc-html-content--base').get_text()
- summary = soup.find('div', class_='summary_text').get_text()
- # print(json.loads(title))
- this_dict = {title: summary}
- print(this_dict)
- except Exception as e:
- print("Invalid movie page!", e)
- check_movie()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement