Skip to content

Instantly share code, notes, and snippets.

@dmarchuk
Created April 30, 2018 22:52
Show Gist options
  • Save dmarchuk/12f0da63b221d6a98dd7efeafdf7d473 to your computer and use it in GitHub Desktop.
Save dmarchuk/12f0da63b221d6a98dd7efeafdf7d473 to your computer and use it in GitHub Desktop.
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