Skip to content

Instantly share code, notes, and snippets.

@kwoods
Created February 29, 2020 15:50
Show Gist options
  • Save kwoods/cdd359dfc2a1a5b605531c17c1b00db0 to your computer and use it in GitHub Desktop.
Save kwoods/cdd359dfc2a1a5b605531c17c1b00db0 to your computer and use it in GitHub Desktop.
import os
import time
from typing import List, Dict
import requests
def get_python_jobs() -> List[Dict]:
jobs = []
page = 0
more_data = True
while more_data:
url = f"https://jobs.github.com/positions.json?description=python&page={page}"
raw_data = requests.get(url)
partial_list = raw_data.json()
jobs.extend(partial_list)
if len(partial_list) < 50: # indicates its likely the last page
more_data = False
time.sleep(.1)
print(f'On page: {page}')
page += 1
return jobs
def save_jobs(data, filename='data.txt'):
with open(filename, 'w', encoding='utf-8') as file:
for item in data:
print(item, file=file)
# Usage:
# jobs = get_python_jobs()
# save_jobs(jobs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment