Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import json
- import requests
- resp = requests.get('https://www.rottentomatoes.com/critic/peter-travers/movies')
- html = resp.text
- json_start = '<script type="application/ld+json">'
- json_end = '</script>'
- json_resp = html[html.find(json_start) + len(json_start) : html.find(json_end, html.find(json_start))].strip()
- json_data = json.loads(json_resp)
- filepath = 'C:\\Users\\alex.ashby\\Documents\\Projects\\RT\\HTML\\'
- filename = 'critic_CriticName_001.html'
- with open(filepath + filename, 'w+') as file:
- file.write(html)
- review_count_start = '"totalReviews":'
- review_count_end = ',"'
- review_count = html[html.find(review_count_start) + len(review_count_start) : html.find(review_count_end, html.find(review_count_start))].strip()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement