Created
February 29, 2020 15:50
-
-
Save kwoods/cdd359dfc2a1a5b605531c17c1b00db0 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 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