Skip to content

Instantly share code, notes, and snippets.

@gfelitti
Last active March 3, 2022 03:02
Show Gist options
  • Select an option

  • Save gfelitti/5b814900b82c82dba67a2a6daa4460c4 to your computer and use it in GitHub Desktop.

Select an option

Save gfelitti/5b814900b82c82dba67a2a6daa4460c4 to your computer and use it in GitHub Desktop.
Como raspar os jsons do https://covid.saude.gov.br/ - se começar a dar problema, tente rotacionar os headers
import requests
import pandas as pd
from pandas.io.json import json_normalize
headers = {
'User-Agent': 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:74.0) Gecko/20100101 Firefox/74.0',
'Accept': 'application/json, text/plain, */*',
'Accept-Language': 'pt-BR,pt;q=0.8,en-US;q=0.5,en;q=0.3',
'X-Parse-Application-Id': 'unAFkcaNDeXajurGB7LChj8SgQYS2ptm',
'Origin': 'https://covid.saude.gov.br',
'Connection': 'keep-alive',
'Referer': 'https://covid.saude.gov.br/',
'DNT': '1',
'TE': 'Trailers',
}
#response = requests.get('https://xx9p7hp1p7.execute-api.us-east-1.amazonaws.com/prod/PortalMapa', headers=headers)
#response = requests.get('https://xx9p7hp1p7.execute-api.us-east-1.amazonaws.com/prod/PortalSemana', headers=headers)
#response = requests.get('https://xx9p7hp1p7.execute-api.us-east-1.amazonaws.com/prod/PortalDias', headers=headers)
#response = requests.get('https://xx9p7hp1p7.execute-api.us-east-1.amazonaws.com/prod/PortalRegiao', headers=headers)
response = requests.get('https://xx9p7hp1p7.execute-api.us-east-1.amazonaws.com/prod/PortalAcumulo', headers=headers)
#response = requests.get('https://xx9p7hp1p7.execute-api.us-east-1.amazonaws.com/prod/PortalGeral', headers=headers)
df=pd.DataFrame(response.json()['results'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment