I want to get some data from github API through python:
import requests
headers = {'User-Agent': 'Awesome-Octocat-App', 'Accept': 'application/vnd.github.preview+json'}
link = "https://github.com/search?q=chembl+created:>=2000"
r = requests.get(link, headers=headers)
and it looks like everything went fine:
r.ok
>>> True
So I would expect to have json in response:
r.json()
But this throws an exception:
JSONDecodeError: No JSON object could be decoded: line 1 column 0 (char 0)
Unfortunately what I have is html:
r.content
<!DOCTYPE html>
<html>
<head prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb# githubog: http://ogp.me/ns/fb/githubog#">
<meta charset='utf-8'>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
...
This html contains all repositories I'm looking for but I need json not html. Why?