How to Use the Python Requests Library for Web Scraping: Web Scraping Tutorial #1

How to Use the Python Requests Library for Web Scraping: Web Scraping Tutorial #1

Note: This tutorial is part of our “Python Web Scraping Tutorial for Beginners” series.

What is Requests?

The requests library in Python is a popular and versatile library for making HTTP requests to interact with web services, retrieve data from websites, and perform various web-related tasks. It simplifies the process of sending HTTP requests and handling responses. You can use the “requests” library for web scraping by sending HTTP GET requests to web pages and then parsing the HTML content of those pages to extract the information you need.

You can install the “requests” library using pip if you haven’t already:

pip install requests

Requests for scraping static websites:

The “requests” library in Python is an essential tool for web scraping static websites. It simplifies the process of making HTTP GET requests to retrieve the HTML content of web pages. With “requests,” you can easily fetch the data from a website and access it as text. While it provides the foundational step of fetching web content, additional libraries like BeautifulSoup(we will see it in our next tutorial) are often used with requests to parse and extract specific information from the HTML. By leveraging the “requests” library, web scrapers can efficiently gather data from static websites, making it a fundamental component of many web scraping projects.

Here is how you can use it:

  • First, import the library
import requests
  • Now we will send a GET request to our targeted website
url = "https://en.wikipedia.org/"
response = requests.get(url)
  • Now get its page source(HTML)
html_content = response.text
# Now, you have the raw HTML content in the 'html_content' variable
print(html_content)

In this way, you can fetch the HTML content of any static website and parse it (we will see it in detail in upcoming tutorials)

Using headers in requests for scraping:

Using headers in requests when scraping websites is essential because, headers allow you to mimic a real web browser’s behavior, providing information about your request to the web server. This can help you avoid being blocked or rate-limited and make your scraping activities appear more legitimate. Websites often use headers to determine the user agent (the browser or client making the request), language preferences, and more. By setting appropriate headers, you can ensure that your web scraping activities are efficient.

Here is how you can send headers:

import requests

# Define headers to mimic a web browser (you can customize these headers)
headers = {
    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.9999.99 Safari/537.36",
    "Accept-Language": "en-US,en;q=0.5",
}

# Specify the URL you want to scrape
url = "https://en.wikipedia.org/"

# Send an HTTP GET request with the custom headers
response = requests.get(url, headers=headers)

#HTML content
print(html_content)

Using requests to scrape data from APIs:

Apis are a way to get data from the server in JSON format. It is the easiest and simplest way to retrieve data. Before scraping a website, you should first check whether this website provides any API or not.
To scrape data from APIs using Python, you can use the requests library to make HTTP requests and retrieve data in JSON format. Here’s a basic example of how to use requests to scrape data from Github API:

First, we will hit the endpoint of API:

import requests

# Make a request to the GitHub API to get a list of users.
response = requests.get('https://api.github.com/users')

Now, we will get JSON data from the response

#json() function will return json data from the response
json_data = response.json()
print(json)

Now you can print JSON data and parse it in the way you want.
Here is the JSON data return from GitHub API.

[
  {
    "login": "mojombo",
    "id": 1,
    "node_id": "MDQ6VXNlcjE=",
    "avatar_url": "https://avatars.githubusercontent.com/u/1?v=4",
    "gravatar_id": "",
    "url": "https://api.github.com/users/mojombo",
    "html_url": "https://github.com/mojombo",
    "followers_url": "https://api.github.com/users/mojombo/followers",
    "following_url": "https://api.github.com/users/mojombo/following{/other_user}",
    "gists_url": "https://api.github.com/users/mojombo/gists{/gist_id}",
    "starred_url": "https://api.github.com/users/mojombo/starred{/owner}{/repo}",
    "subscriptions_url": "https://api.github.com/users/mojombo/subscriptions",
    "organizations_url": "https://api.github.com/users/mojombo/orgs",
    "repos_url": "https://api.github.com/users/mojombo/repos",
    "events_url": "https://api.github.com/users/mojombo/events{/privacy}",
    "received_events_url": "https://api.github.com/users/mojombo/received_events",
    "type": "User",
    "site_admin": false
  },
  {
    "login": "defunkt",
    "id": 2,
    "node_id": "MDQ6VXNlcjI=",
    "avatar_url": "https://avatars.githubusercontent.com/u/2?v=4",
    "gravatar_id": "",
    "url": "https://api.github.com/users/defunkt",
    "html_url": "https://github.com/defunkt",
    "followers_url": "https://api.github.com/users/defunkt/followers",
    "following_url": "https://api.github.com/users/defunkt/following{/other_user}",
    "gists_url": "https://api.github.com/users/defunkt/gists{/gist_id}",
    "starred_url": "https://api.github.com/users/defunkt/starred{/owner}{/repo}",
    "subscriptions_url": "https://api.github.com/users/defunkt/subscriptions",
    "organizations_url": "https://api.github.com/users/defunkt/orgs",
    "repos_url": "https://api.github.com/users/defunkt/repos",
    "events_url": "https://api.github.com/users/defunkt/events{/privacy}",
    "received_events_url": "https://api.github.com/users/defunkt/received_events",
    "type": "User",
    "site_admin": false
  },
  {
    "login": "pjhyett",
    "id": 3,
    "node_id": "MDQ6VXNlcjM=",
    "avatar_url": "https://avatars.githubusercontent.com/u/3?v=4",
    "gravatar_id": "",
    "url": "https://api.github.com/users/pjhyett",
    "html_url": "https://github.com/pjhyett",
    "followers_url": "https://api.github.com/users/pjhyett/followers",
    "following_url": "https://api.github.com/users/pjhyett/following{/other_user}",
    "gists_url": "https://api.github.com/users/pjhyett/gists{/gist_id}",
    "starred_url": "https://api.github.com/users/pjhyett/starred{/owner}{/repo}",
    "subscriptions_url": "https://api.github.com/users/pjhyett/subscriptions",
    "organizations_url": "https://api.github.com/users/pjhyett/orgs",
    "repos_url": "https://api.github.com/users/pjhyett/repos",
    "events_url": "https://api.github.com/users/pjhyett/events{/privacy}",
    "received_events_url": "https://api.github.com/users/pjhyett/received_events",
    "type": "User",
    "site_admin": false
  },
  {
    "login": "wycats",
    "id": 4,
    "node_id": "MDQ6VXNlcjQ=",
    "avatar_url": "https://avatars.githubusercontent.com/u/4?v=4",
    "gravatar_id": "",
    "url": "https://api.github.com/users/wycats",
    "html_url": "https://github.com/wycats",
    "followers_url": "https://api.github.com/users/wycats/followers",
    "following_url": "https://api.github.com/users/wycats/following{/other_user}",
    "gists_url": "https://api.github.com/users/wycats/gists{/gist_id}",
    "starred_url": "https://api.github.com/users/wycats/starred{/owner}{/repo}",
    "subscriptions_url": "https://api.github.com/users/wycats/subscriptions",
    "organizations_url": "https://api.github.com/users/wycats/orgs",
    "repos_url": "https://api.github.com/users/wycats/repos",
    "events_url": "https://api.github.com/users/wycats/events{/privacy}",
    "received_events_url": "https://api.github.com/users/wycats/received_events",
    "type": "User",
    "site_admin": false
  },
  {
    "login": "ezmobius",
    "id": 5,
    "node_id": "MDQ6VXNlcjU=",
    "avatar_url": "https://avatars.githubusercontent.com/u/5?v=4",
    "gravatar_id": "",
    "url": "https://api.github.com/users/ezmobius",
    "html_url": "https://github.com/ezmobius",
    "followers_url": "https://api.github.com/users/ezmobius/followers",
    "following_url": "https://api.github.com/users/ezmobius/following{/other_user}",
    "gists_url": "https://api.github.com/users/ezmobius/gists{/gist_id}",
    "starred_url": "https://api.github.com/users/ezmobius/starred{/owner}{/repo}",
    "subscriptions_url": "https://api.github.com/users/ezmobius/subscriptions",
    "organizations_url": "https://api.github.com/users/ezmobius/orgs",
    "repos_url": "https://api.github.com/users/ezmobius/repos",
    "events_url": "https://api.github.com/users/ezmobius/events{/privacy}",
    "received_events_url": "https://api.github.com/users/ezmobius/received_events",
    "type": "User",
    "site_admin": false
  },
  {
    "login": "ivey",
    "id": 6,
    "node_id": "MDQ6VXNlcjY=",
    "avatar_url": "https://avatars.githubusercontent.com/u/6?v=4",
    "gravatar_id": "",
    "url": "https://api.github.com/users/ivey",
    "html_url": "https://github.com/ivey",
    "followers_url": "https://api.github.com/users/ivey/followers",
    "following_url": "https://api.github.com/users/ivey/following{/other_user}",
    "gists_url": "https://api.github.com/users/ivey/gists{/gist_id}",
    "starred_url": "https://api.github.com/users/ivey/starred{/owner}{/repo}",
    "subscriptions_url": "https://api.github.com/users/ivey/subscriptions",
    "organizations_url": "https://api.github.com/users/ivey/orgs",
    "repos_url": "https://api.github.com/users/ivey/repos",
    "events_url": "https://api.github.com/users/ivey/events{/privacy}",
    "received_events_url": "https://api.github.com/users/ivey/received_events",
    "type": "User",
    "site_admin": false
  },
  {
    "login": "evanphx",
    "id": 7,
    "node_id": "MDQ6VXNlcjc=",
    "avatar_url": "https://avatars.githubusercontent.com/u/7?v=4",
    "gravatar_id": "",
    "url": "https://api.github.com/users/evanphx",
    "html_url": "https://github.com/evanphx",
    "followers_url": "https://api.github.com/users/evanphx/followers",
    "following_url": "https://api.github.com/users/evanphx/following{/other_user}",
    "gists_url": "https://api.github.com/users/evanphx/gists{/gist_id}",
    "starred_url": "https://api.github.com/users/evanphx/starred{/owner}{/repo}",
    "subscriptions_url": "https://api.github.com/users/evanphx/subscriptions",
    "organizations_url": "https://api.github.com/users/evanphx/orgs",
    "repos_url": "https://api.github.com/users/evanphx/repos",
    "events_url": "https://api.github.com/users/evanphx/events{/privacy}",
    "received_events_url": "https://api.github.com/users/evanphx/received_events",
    "type": "User",
    "site_admin": false
  },
  {
    "login": "vanpelt",
    "id": 17,
    "node_id": "MDQ6VXNlcjE3",
    "avatar_url": "https://avatars.githubusercontent.com/u/17?v=4",
    "gravatar_id": "",
    "url": "https://api.github.com/users/vanpelt",
    "html_url": "https://github.com/vanpelt",
    "followers_url": "https://api.github.com/users/vanpelt/followers",
    "following_url": "https://api.github.com/users/vanpelt/following{/other_user}",
    "gists_url": "https://api.github.com/users/vanpelt/gists{/gist_id}",
    "starred_url": "https://api.github.com/users/vanpelt/starred{/owner}{/repo}",
    "subscriptions_url": "https://api.github.com/users/vanpelt/subscriptions",
    "organizations_url": "https://api.github.com/users/vanpelt/orgs",
    "repos_url": "https://api.github.com/users/vanpelt/repos",
    "events_url": "https://api.github.com/users/vanpelt/events{/privacy}",
    "received_events_url": "https://api.github.com/users/vanpelt/received_events",
    "type": "User",
    "site_admin": false
  },
  {
    "login": "wayneeseguin",
    "id": 18,
    "node_id": "MDQ6VXNlcjE4",
    "avatar_url": "https://avatars.githubusercontent.com/u/18?v=4",
    "gravatar_id": "",
    "url": "https://api.github.com/users/wayneeseguin",
    "html_url": "https://github.com/wayneeseguin",
    "followers_url": "https://api.github.com/users/wayneeseguin/followers",
    "following_url": "https://api.github.com/users/wayneeseguin/following{/other_user}",
    "gists_url": "https://api.github.com/users/wayneeseguin/gists{/gist_id}",
    "starred_url": "https://api.github.com/users/wayneeseguin/starred{/owner}{/repo}",
    "subscriptions_url": "https://api.github.com/users/wayneeseguin/subscriptions",
    "organizations_url": "https://api.github.com/users/wayneeseguin/orgs",
    "repos_url": "https://api.github.com/users/wayneeseguin/repos",
    "events_url": "https://api.github.com/users/wayneeseguin/events{/privacy}",
    "received_events_url": "https://api.github.com/users/wayneeseguin/received_events",
    "type": "User",
    "site_admin": false
  },
  {
    "login": "brynary",
    "id": 19,
    "node_id": "MDQ6VXNlcjE5",
    "avatar_url": "https://avatars.githubusercontent.com/u/19?v=4",
    "gravatar_id": "",
    "url": "https://api.github.com/users/brynary",
    "html_url": "https://github.com/brynary",
    "followers_url": "https://api.github.com/users/brynary/followers",
    "following_url": "https://api.github.com/users/brynary/following{/other_user}",
    "gists_url": "https://api.github.com/users/brynary/gists{/gist_id}",
    "starred_url": "https://api.github.com/users/brynary/starred{/owner}{/repo}",
    "subscriptions_url": "https://api.github.com/users/brynary/subscriptions",
    "organizations_url": "https://api.github.com/users/brynary/orgs",
    "repos_url": "https://api.github.com/users/brynary/repos",
    "events_url": "https://api.github.com/users/brynary/events{/privacy}",
    "received_events_url": "https://api.github.com/users/brynary/received_events",
    "type": "User",
    "site_admin": false
  },
  {
    "login": "kevinclark",
    "id": 20,
    "node_id": "MDQ6VXNlcjIw",
    "avatar_url": "https://avatars.githubusercontent.com/u/20?v=4",
    "gravatar_id": "",
    "url": "https://api.github.com/users/kevinclark",
    "html_url": "https://github.com/kevinclark",
    "followers_url": "https://api.github.com/users/kevinclark/followers",
    "following_url": "https://api.github.com/users/kevinclark/following{/other_user}",
    "gists_url": "https://api.github.com/users/kevinclark/gists{/gist_id}",
    "starred_url": "https://api.github.com/users/kevinclark/starred{/owner}{/repo}",
    "subscriptions_url": "https://api.github.com/users/kevinclark/subscriptions",
    "organizations_url": "https://api.github.com/users/kevinclark/orgs",
    "repos_url": "https://api.github.com/users/kevinclark/repos",
    "events_url": "https://api.github.com/users/kevinclark/events{/privacy}",
    "received_events_url": "https://api.github.com/users/kevinclark/received_events",
    "type": "User",
    "site_admin": false
  },
  {
    "login": "technoweenie",
    "id": 21,
    "node_id": "MDQ6VXNlcjIx",
    "avatar_url": "https://avatars.githubusercontent.com/u/21?v=4",
    "gravatar_id": "",
    "url": "https://api.github.com/users/technoweenie",
    "html_url": "https://github.com/technoweenie",
    "followers_url": "https://api.github.com/users/technoweenie/followers",
    "following_url": "https://api.github.com/users/technoweenie/following{/other_user}",
    "gists_url": "https://api.github.com/users/technoweenie/gists{/gist_id}",
    "starred_url": "https://api.github.com/users/technoweenie/starred{/owner}{/repo}",
    "subscriptions_url": "https://api.github.com/users/technoweenie/subscriptions",
    "organizations_url": "https://api.github.com/users/technoweenie/orgs",
    "repos_url": "https://api.github.com/users/technoweenie/repos",
    "events_url": "https://api.github.com/users/technoweenie/events{/privacy}",
    "received_events_url": "https://api.github.com/users/technoweenie/received_events",
    "type": "User",
    "site_admin": false
  },
  {
    "login": "macournoyer",
    "id": 22,
    "node_id": "MDQ6VXNlcjIy",
    "avatar_url": "https://avatars.githubusercontent.com/u/22?v=4",
    "gravatar_id": "",
    "url": "https://api.github.com/users/macournoyer",
    "html_url": "https://github.com/macournoyer",
    "followers_url": "https://api.github.com/users/macournoyer/followers",
    "following_url": "https://api.github.com/users/macournoyer/following{/other_user}",
    "gists_url": "https://api.github.com/users/macournoyer/gists{/gist_id}",
    "starred_url": "https://api.github.com/users/macournoyer/starred{/owner}{/repo}",
    "subscriptions_url": "https://api.github.com/users/macournoyer/subscriptions",
    "organizations_url": "https://api.github.com/users/macournoyer/orgs",
    "repos_url": "https://api.github.com/users/macournoyer/repos",
    "events_url": "https://api.github.com/users/macournoyer/events{/privacy}",
    "received_events_url": "https://api.github.com/users/macournoyer/received_events",
    "type": "User",
    "site_admin": false
  },
  {
    "login": "takeo",
    "id": 23,
    "node_id": "MDQ6VXNlcjIz",
    "avatar_url": "https://avatars.githubusercontent.com/u/23?v=4",
    "gravatar_id": "",
    "url": "https://api.github.com/users/takeo",
    "html_url": "https://github.com/takeo",
    "followers_url": "https://api.github.com/users/takeo/followers",
    "following_url": "https://api.github.com/users/takeo/following{/other_user}",
    "gists_url": "https://api.github.com/users/takeo/gists{/gist_id}",
    "starred_url": "https://api.github.com/users/takeo/starred{/owner}{/repo}",
    "subscriptions_url": "https://api.github.com/users/takeo/subscriptions",
    "organizations_url": "https://api.github.com/users/takeo/orgs",
    "repos_url": "https://api.github.com/users/takeo/repos",
    "events_url": "https://api.github.com/users/takeo/events{/privacy}",
    "received_events_url": "https://api.github.com/users/takeo/received_events",
    "type": "User",
    "site_admin": false
  },
  {
    "login": "caged",
    "id": 25,
    "node_id": "MDQ6VXNlcjI1",
    "avatar_url": "https://avatars.githubusercontent.com/u/25?v=4",
    "gravatar_id": "",
    "url": "https://api.github.com/users/caged",
    "html_url": "https://github.com/caged",
    "followers_url": "https://api.github.com/users/caged/followers",
    "following_url": "https://api.github.com/users/caged/following{/other_user}",
    "gists_url": "https://api.github.com/users/caged/gists{/gist_id}",
    "starred_url": "https://api.github.com/users/caged/starred{/owner}{/repo}",
    "subscriptions_url": "https://api.github.com/users/caged/subscriptions",
    "organizations_url": "https://api.github.com/users/caged/orgs",
    "repos_url": "https://api.github.com/users/caged/repos",
    "events_url": "https://api.github.com/users/caged/events{/privacy}",
    "received_events_url": "https://api.github.com/users/caged/received_events",
    "type": "User",
    "site_admin": false
  },
  {
    "login": "topfunky",
    "id": 26,
    "node_id": "MDQ6VXNlcjI2",
    "avatar_url": "https://avatars.githubusercontent.com/u/26?v=4",
    "gravatar_id": "",
    "url": "https://api.github.com/users/topfunky",
    "html_url": "https://github.com/topfunky",
    "followers_url": "https://api.github.com/users/topfunky/followers",
    "following_url": "https://api.github.com/users/topfunky/following{/other_user}",
    "gists_url": "https://api.github.com/users/topfunky/gists{/gist_id}",
    "starred_url": "https://api.github.com/users/topfunky/starred{/owner}{/repo}",
    "subscriptions_url": "https://api.github.com/users/topfunky/subscriptions",
    "organizations_url": "https://api.github.com/users/topfunky/orgs",
    "repos_url": "https://api.github.com/users/topfunky/repos",
    "events_url": "https://api.github.com/users/topfunky/events{/privacy}",
    "received_events_url": "https://api.github.com/users/topfunky/received_events",
    "type": "User",
    "site_admin": false
  },
  {
    "login": "anotherjesse",
    "id": 27,
    "node_id": "MDQ6VXNlcjI3",
    "avatar_url": "https://avatars.githubusercontent.com/u/27?v=4",
    "gravatar_id": "",
    "url": "https://api.github.com/users/anotherjesse",
    "html_url": "https://github.com/anotherjesse",
    "followers_url": "https://api.github.com/users/anotherjesse/followers",
    "following_url": "https://api.github.com/users/anotherjesse/following{/other_user}",
    "gists_url": "https://api.github.com/users/anotherjesse/gists{/gist_id}",
    "starred_url": "https://api.github.com/users/anotherjesse/starred{/owner}{/repo}",
    "subscriptions_url": "https://api.github.com/users/anotherjesse/subscriptions",
    "organizations_url": "https://api.github.com/users/anotherjesse/orgs",
    "repos_url": "https://api.github.com/users/anotherjesse/repos",
    "events_url": "https://api.github.com/users/anotherjesse/events{/privacy}",
    "received_events_url": "https://api.github.com/users/anotherjesse/received_events",
    "type": "User",
    "site_admin": false
  },
  {
    "login": "roland",
    "id": 28,
    "node_id": "MDQ6VXNlcjI4",
    "avatar_url": "https://avatars.githubusercontent.com/u/28?v=4",
    "gravatar_id": "",
    "url": "https://api.github.com/users/roland",
    "html_url": "https://github.com/roland",
    "followers_url": "https://api.github.com/users/roland/followers",
    "following_url": "https://api.github.com/users/roland/following{/other_user}",
    "gists_url": "https://api.github.com/users/roland/gists{/gist_id}",
    "starred_url": "https://api.github.com/users/roland/starred{/owner}{/repo}",
    "subscriptions_url": "https://api.github.com/users/roland/subscriptions",
    "organizations_url": "https://api.github.com/users/roland/orgs",
    "repos_url": "https://api.github.com/users/roland/repos",
    "events_url": "https://api.github.com/users/roland/events{/privacy}",
    "received_events_url": "https://api.github.com/users/roland/received_events",
    "type": "User",
    "site_admin": false
  },
  {
    "login": "lukas",
    "id": 29,
    "node_id": "MDQ6VXNlcjI5",
    "avatar_url": "https://avatars.githubusercontent.com/u/29?v=4",
    "gravatar_id": "",
    "url": "https://api.github.com/users/lukas",
    "html_url": "https://github.com/lukas",
    "followers_url": "https://api.github.com/users/lukas/followers",
    "following_url": "https://api.github.com/users/lukas/following{/other_user}",
    "gists_url": "https://api.github.com/users/lukas/gists{/gist_id}",
    "starred_url": "https://api.github.com/users/lukas/starred{/owner}{/repo}",
    "subscriptions_url": "https://api.github.com/users/lukas/subscriptions",
    "organizations_url": "https://api.github.com/users/lukas/orgs",
    "repos_url": "https://api.github.com/users/lukas/repos",
    "events_url": "https://api.github.com/users/lukas/events{/privacy}",
    "received_events_url": "https://api.github.com/users/lukas/received_events",
    "type": "User",
    "site_admin": false
  },
  {
    "login": "fanvsfan",
    "id": 30,
    "node_id": "MDQ6VXNlcjMw",
    "avatar_url": "https://avatars.githubusercontent.com/u/30?v=4",
    "gravatar_id": "",
    "url": "https://api.github.com/users/fanvsfan",
    "html_url": "https://github.com/fanvsfan",
    "followers_url": "https://api.github.com/users/fanvsfan/followers",
    "following_url": "https://api.github.com/users/fanvsfan/following{/other_user}",
    "gists_url": "https://api.github.com/users/fanvsfan/gists{/gist_id}",
    "starred_url": "https://api.github.com/users/fanvsfan/starred{/owner}{/repo}",
    "subscriptions_url": "https://api.github.com/users/fanvsfan/subscriptions",
    "organizations_url": "https://api.github.com/users/fanvsfan/orgs",
    "repos_url": "https://api.github.com/users/fanvsfan/repos",
    "events_url": "https://api.github.com/users/fanvsfan/events{/privacy}",
    "received_events_url": "https://api.github.com/users/fanvsfan/received_events",
    "type": "User",
    "site_admin": false
  },
  {
    "login": "tomtt",
    "id": 31,
    "node_id": "MDQ6VXNlcjMx",
    "avatar_url": "https://avatars.githubusercontent.com/u/31?v=4",
    "gravatar_id": "",
    "url": "https://api.github.com/users/tomtt",
    "html_url": "https://github.com/tomtt",
    "followers_url": "https://api.github.com/users/tomtt/followers",
    "following_url": "https://api.github.com/users/tomtt/following{/other_user}",
    "gists_url": "https://api.github.com/users/tomtt/gists{/gist_id}",
    "starred_url": "https://api.github.com/users/tomtt/starred{/owner}{/repo}",
    "subscriptions_url": "https://api.github.com/users/tomtt/subscriptions",
    "organizations_url": "https://api.github.com/users/tomtt/orgs",
    "repos_url": "https://api.github.com/users/tomtt/repos",
    "events_url": "https://api.github.com/users/tomtt/events{/privacy}",
    "received_events_url": "https://api.github.com/users/tomtt/received_events",
    "type": "User",
    "site_admin": false
  },
  {
    "login": "railsjitsu",
    "id": 32,
    "node_id": "MDQ6VXNlcjMy",
    "avatar_url": "https://avatars.githubusercontent.com/u/32?v=4",
    "gravatar_id": "",
    "url": "https://api.github.com/users/railsjitsu",
    "html_url": "https://github.com/railsjitsu",
    "followers_url": "https://api.github.com/users/railsjitsu/followers",
    "following_url": "https://api.github.com/users/railsjitsu/following{/other_user}",
    "gists_url": "https://api.github.com/users/railsjitsu/gists{/gist_id}",
    "starred_url": "https://api.github.com/users/railsjitsu/starred{/owner}{/repo}",
    "subscriptions_url": "https://api.github.com/users/railsjitsu/subscriptions",
    "organizations_url": "https://api.github.com/users/railsjitsu/orgs",
    "repos_url": "https://api.github.com/users/railsjitsu/repos",
    "events_url": "https://api.github.com/users/railsjitsu/events{/privacy}",
    "received_events_url": "https://api.github.com/users/railsjitsu/received_events",
    "type": "User",
    "site_admin": false
  },
  {
    "login": "nitay",
    "id": 34,
    "node_id": "MDQ6VXNlcjM0",
    "avatar_url": "https://avatars.githubusercontent.com/u/34?v=4",
    "gravatar_id": "",
    "url": "https://api.github.com/users/nitay",
    "html_url": "https://github.com/nitay",
    "followers_url": "https://api.github.com/users/nitay/followers",
    "following_url": "https://api.github.com/users/nitay/following{/other_user}",
    "gists_url": "https://api.github.com/users/nitay/gists{/gist_id}",
    "starred_url": "https://api.github.com/users/nitay/starred{/owner}{/repo}",
    "subscriptions_url": "https://api.github.com/users/nitay/subscriptions",
    "organizations_url": "https://api.github.com/users/nitay/orgs",
    "repos_url": "https://api.github.com/users/nitay/repos",
    "events_url": "https://api.github.com/users/nitay/events{/privacy}",
    "received_events_url": "https://api.github.com/users/nitay/received_events",
    "type": "User",
    "site_admin": false
  },
  {
    "login": "kevwil",
    "id": 35,
    "node_id": "MDQ6VXNlcjM1",
    "avatar_url": "https://avatars.githubusercontent.com/u/35?v=4",
    "gravatar_id": "",
    "url": "https://api.github.com/users/kevwil",
    "html_url": "https://github.com/kevwil",
    "followers_url": "https://api.github.com/users/kevwil/followers",
    "following_url": "https://api.github.com/users/kevwil/following{/other_user}",
    "gists_url": "https://api.github.com/users/kevwil/gists{/gist_id}",
    "starred_url": "https://api.github.com/users/kevwil/starred{/owner}{/repo}",
    "subscriptions_url": "https://api.github.com/users/kevwil/subscriptions",
    "organizations_url": "https://api.github.com/users/kevwil/orgs",
    "repos_url": "https://api.github.com/users/kevwil/repos",
    "events_url": "https://api.github.com/users/kevwil/events{/privacy}",
    "received_events_url": "https://api.github.com/users/kevwil/received_events",
    "type": "User",
    "site_admin": false
  },
  {
    "login": "KirinDave",
    "id": 36,
    "node_id": "MDQ6VXNlcjM2",
    "avatar_url": "https://avatars.githubusercontent.com/u/36?v=4",
    "gravatar_id": "",
    "url": "https://api.github.com/users/KirinDave",
    "html_url": "https://github.com/KirinDave",
    "followers_url": "https://api.github.com/users/KirinDave/followers",
    "following_url": "https://api.github.com/users/KirinDave/following{/other_user}",
    "gists_url": "https://api.github.com/users/KirinDave/gists{/gist_id}",
    "starred_url": "https://api.github.com/users/KirinDave/starred{/owner}{/repo}",
    "subscriptions_url": "https://api.github.com/users/KirinDave/subscriptions",
    "organizations_url": "https://api.github.com/users/KirinDave/orgs",
    "repos_url": "https://api.github.com/users/KirinDave/repos",
    "events_url": "https://api.github.com/users/KirinDave/events{/privacy}",
    "received_events_url": "https://api.github.com/users/KirinDave/received_events",
    "type": "User",
    "site_admin": false
  },
  {
    "login": "jamesgolick",
    "id": 37,
    "node_id": "MDQ6VXNlcjM3",
    "avatar_url": "https://avatars.githubusercontent.com/u/37?v=4",
    "gravatar_id": "",
    "url": "https://api.github.com/users/jamesgolick",
    "html_url": "https://github.com/jamesgolick",
    "followers_url": "https://api.github.com/users/jamesgolick/followers",
    "following_url": "https://api.github.com/users/jamesgolick/following{/other_user}",
    "gists_url": "https://api.github.com/users/jamesgolick/gists{/gist_id}",
    "starred_url": "https://api.github.com/users/jamesgolick/starred{/owner}{/repo}",
    "subscriptions_url": "https://api.github.com/users/jamesgolick/subscriptions",
    "organizations_url": "https://api.github.com/users/jamesgolick/orgs",
    "repos_url": "https://api.github.com/users/jamesgolick/repos",
    "events_url": "https://api.github.com/users/jamesgolick/events{/privacy}",
    "received_events_url": "https://api.github.com/users/jamesgolick/received_events",
    "type": "User",
    "site_admin": false
  },
  {
    "login": "atmos",
    "id": 38,
    "node_id": "MDQ6VXNlcjM4",
    "avatar_url": "https://avatars.githubusercontent.com/u/38?v=4",
    "gravatar_id": "",
    "url": "https://api.github.com/users/atmos",
    "html_url": "https://github.com/atmos",
    "followers_url": "https://api.github.com/users/atmos/followers",
    "following_url": "https://api.github.com/users/atmos/following{/other_user}",
    "gists_url": "https://api.github.com/users/atmos/gists{/gist_id}",
    "starred_url": "https://api.github.com/users/atmos/starred{/owner}{/repo}",
    "subscriptions_url": "https://api.github.com/users/atmos/subscriptions",
    "organizations_url": "https://api.github.com/users/atmos/orgs",
    "repos_url": "https://api.github.com/users/atmos/repos",
    "events_url": "https://api.github.com/users/atmos/events{/privacy}",
    "received_events_url": "https://api.github.com/users/atmos/received_events",
    "type": "User",
    "site_admin": false
  },
  {
    "login": "errfree",
    "id": 44,
    "node_id": "MDEyOk9yZ2FuaXphdGlvbjQ0",
    "avatar_url": "https://avatars.githubusercontent.com/u/44?v=4",
    "gravatar_id": "",
    "url": "https://api.github.com/users/errfree",
    "html_url": "https://github.com/errfree",
    "followers_url": "https://api.github.com/users/errfree/followers",
    "following_url": "https://api.github.com/users/errfree/following{/other_user}",
    "gists_url": "https://api.github.com/users/errfree/gists{/gist_id}",
    "starred_url": "https://api.github.com/users/errfree/starred{/owner}{/repo}",
    "subscriptions_url": "https://api.github.com/users/errfree/subscriptions",
    "organizations_url": "https://api.github.com/users/errfree/orgs",
    "repos_url": "https://api.github.com/users/errfree/repos",
    "events_url": "https://api.github.com/users/errfree/events{/privacy}",
    "received_events_url": "https://api.github.com/users/errfree/received_events",
    "type": "Organization",
    "site_admin": false
  },
  {
    "login": "mojodna",
    "id": 45,
    "node_id": "MDQ6VXNlcjQ1",
    "avatar_url": "https://avatars.githubusercontent.com/u/45?v=4",
    "gravatar_id": "",
    "url": "https://api.github.com/users/mojodna",
    "html_url": "https://github.com/mojodna",
    "followers_url": "https://api.github.com/users/mojodna/followers",
    "following_url": "https://api.github.com/users/mojodna/following{/other_user}",
    "gists_url": "https://api.github.com/users/mojodna/gists{/gist_id}",
    "starred_url": "https://api.github.com/users/mojodna/starred{/owner}{/repo}",
    "subscriptions_url": "https://api.github.com/users/mojodna/subscriptions",
    "organizations_url": "https://api.github.com/users/mojodna/orgs",
    "repos_url": "https://api.github.com/users/mojodna/repos",
    "events_url": "https://api.github.com/users/mojodna/events{/privacy}",
    "received_events_url": "https://api.github.com/users/mojodna/received_events",
    "type": "User",
    "site_admin": false
  },
  {
    "login": "bmizerany",
    "id": 46,
    "node_id": "MDQ6VXNlcjQ2",
    "avatar_url": "https://avatars.githubusercontent.com/u/46?v=4",
    "gravatar_id": "",
    "url": "https://api.github.com/users/bmizerany",
    "html_url": "https://github.com/bmizerany",
    "followers_url": "https://api.github.com/users/bmizerany/followers",
    "following_url": "https://api.github.com/users/bmizerany/following{/other_user}",
    "gists_url": "https://api.github.com/users/bmizerany/gists{/gist_id}",
    "starred_url": "https://api.github.com/users/bmizerany/starred{/owner}{/repo}",
    "subscriptions_url": "https://api.github.com/users/bmizerany/subscriptions",
    "organizations_url": "https://api.github.com/users/bmizerany/orgs",
    "repos_url": "https://api.github.com/users/bmizerany/repos",
    "events_url": "https://api.github.com/users/bmizerany/events{/privacy}",
    "received_events_url": "https://api.github.com/users/bmizerany/received_events",
    "type": "User",
    "site_admin": false
  }
]

For example, if you want to extract the names of users. You can do this in this way:

for user in json_data:
    print(user['login'])
Scroll to Top