Skip to content

Instantly share code, notes, and snippets.

url = 'http://api.scraperapi.com?api_key={YOUR_API_KEY}&url={TARGET_URL}'
import requests
import csv
url = 'https://datatables.net/examples/ajax/data/arrays.txt?_=1656247207356'
headers = {
'value': 'application/json, text/javascript, */*; q=0.01',
'accept': 'application/json, text/javascript, */*; q=0.01',
'cookie': 'PHPSESSID=196d9e692bf75bea701ea53461032689; __utmc=120757021; __utmz=120757021.1655866355.1.1.utmcsr=bing|utmccn=(organic)|utmcmd=organic|utmctr=(not provided); __utma=120757021.1861635672.1655866355.1656246692.1656255144.5'
}
file.close()
print('CSV created')
writer.writerow([
name.encode('utf-8'),
position.encode('utf-8'),
office.encode('utf-8'),
extn.encode('utf-8'),
start_date.encode('utf-8'),
salary.encode('utf-8')])
file = open('js-table-data.csv', 'w')
writer = csv.writer(file)
writer.writerow(['Name', 'Position', 'Office', 'Start Date', 'Extn', 'Salary'])
data = page.json()
for item in data['data']:
name = item[0]
position = item[1]
office = item[2]
extn = item[3]
start_date = item[4]
salary = item[5]
all_arrays = data['data']
print(len(all_arrays))
data = page.json()
first_array = data['data'][0]
print(first_array)
data = page.json()
print(len(data))
import requests
url = 'https://datatables.net/examples/ajax/data/arrays.txt?_=1656247207356'
headers = {
'value': 'application/json, text/javascript, */*; q=0.01',
'accept': 'application/json, text/javascript, */*; q=0.01',
'cookie': 'PHPSESSID=196d9e692bf75bea701ea53461032689; __utmc=120757021; __utmz=120757021.1655866355.1.1.utmcsr=bing|utmccn=(organic)|utmcmd=organic|utmctr=(not provided); __utma=120757021.1861635672.1655866355.1656246692.1656255144.5'
}
page = requests.get(url, headers=headers)