Created
April 30, 2018 22:52
-
-
Save dmarchuk/12f0da63b221d6a98dd7efeafdf7d473 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import csv | |
import requests | |
result = '' | |
for i in range(195): | |
list_json = requests.get(url, headers={ | |
'X-Requested-With': 'XMLHttpRequest', | |
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36', | |
'Accept': '*/*', | |
'Host': 'www.google.com', | |
'Connection': 'keep-alive', | |
'Pragma': 'no-cache', | |
'Cache-Control': 'no-cache' | |
}).json() | |
result += list_json['snippets-obj'] | |
try: | |
file = open('test.html', 'w') | |
except IOError: | |
file = open('test.html', 'w') | |
html = '<html><body>{}</body></html>'.format("".join(result.encode('UTF-8').strip())) | |
file.write(html) | |
file.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment