How to Scrape Indeed.com (2023 Update)

article feature image

In this web scraping tutorial, we'll take a look at how to scrape job listing data from Indeed.com.

Indeed.com is one of the most popular job listing websites, and it's pretty easy to scrape!
In this tutorial, we'll build our scraper with just a few lines of Python code. We'll take a look at how Indeed's search works to replicate it in our scraper and extract job data from embedded javascript variables. Let's dive in!

Latest Indeed.com Scraper Code

https://github.com/scrapfly/scrapfly-scrapers/

Project Setup

For this web scraper, we'll only need an HTTP client library such as httpx library, which can be installed through pip console command:

$ pip install httpx 

There are many HTTP clients in Python like requests, httpx, aiohttp, etc. however, we recommend httpx as it's the least one likely to be blocked as it supports http2 protocol. httpx also supports asynchronous python, which means we can scrape really fast!

For ScrapFly users, we'll also be providing code versions using scrapfly-sdk.

Hands on Python Web Scraping Tutorial and Example Project

If you're new to web scraping with Python we recommend checking out our full introduction tutorial to web scraping with Python and common best practices.

Hands on Python Web Scraping Tutorial and Example Project

Finding Indeed Jobs

To start, let's take a look at how we can find job listings on Indeed.com.
If we go to the homepage and submit our search, we can see that Indeed redirects us to a search URL with a few key parameters:

0:00
/
https://www.indeed.com/jobs?q=python&l=Texas

So, to find Python jobs in Texas, all we have to do is send a request with l=Texas and q=Python URL parameters:

Python
ScrapFly
import httpx
HEADERS = {
    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36",
    "Accept-Encoding": "gzip, deflate, br",
    "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
    "Connection": "keep-alive",
    "Accept-Language": "en-US,en;q=0.9,lt;q=0.8,et;q=0.7,de;q=0.6",
}

response = httpx.get("https://www.indeed.com/jobs?q=python&l=Texas", headers=HEADERS)
print(response)
from scrapfly import ScrapflyClient, ScrapeConfig


scrapfly = ScrapflyClient(key="YOUR SCRAPFLY KEY")
result = scrapfly.scrape(ScrapeConfig(
    url="https://www.indeed.com/jobs?q=python&l=Texas",
    asp=True,
))
print(result.selector.xpath('//h1').get())

Note: if you receive response status code 403 here, it's likely you are being blocked, see Avoiding Blocking section below for more information.

We got a single page that contains 15 job listings! Before we collect the remaining pages, let's see how we can parse job listing data from this response.

We could parse the HTML document using CSS or XPath selectors, but there's an easier way: we can find all of the job listing data hidden away deep in the HTML as a JSON document:

page source of indeed.com search page embedded ddata

So, instead, let's parse this data using a simple regular expression pattern:

Python
ScrapFly
import httpx
import re
import json

HEADERS = {
    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36",
    "Accept-Encoding": "gzip, deflate, br",
    "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
    "Connection": "keep-alive",
    "Accept-Language": "en-US,en;q=0.9,lt;q=0.8,et;q=0.7,de;q=0.6",
}


def parse_search_page(html: str):
    data = re.findall(r'window.mosaic.providerData\["mosaic-provider-jobcards"\]=(\{.+?\});', html)
    data = json.loads(data[0])
    return {
        "results": data["metaData"]["mosaicProviderJobCardsModel"]["results"],
        "meta": data["metaData"]["mosaicProviderJobCardsModel"]["tierSummaries"],
    }


response = httpx.get("https://www.indeed.com/jobs?q=python&l=Texas", headers=HEADERS)
print(parse_search_page(response.text))
import re
import json
import os
from scrapfly import ScrapflyClient, ScrapeConfig


scrapfly = ScrapflyClient(os.environ["SCRAPFLY_KEY"])


def parse_search_page(html: str):
    data = re.findall(r'window.mosaic.providerData\["mosaic-provider-jobcards"\]=(\{.+?\});', html)
    data = json.loads(data[0])
    return {
        "results": data["metaData"]["mosaicProviderJobCardsModel"]["results"],
        "meta": data["metaData"]["mosaicProviderJobCardsModel"]["tierSummaries"],
    }


result = scrapfly.scrape(
    ScrapeConfig(
        url="https://www.indeed.com/jobs?q=python&l=Texas",
        asp=True,
    )
)
print(parse_search_page(result.content))

In our code above, we are using a regular expression pattern to select mosaic-provider-jobcards variable value, load it as a python dictionary and parse out the result and paging meta-data.

Now that we have the first page results and total page count, we can retrieve the remaining pages:

Python
ScrapFly
import asyncio
import json
import re
from urllib.parse import urlencode

import httpx


def parse_search_page(html: str):
    data = re.findall(r'window.mosaic.providerData\["mosaic-provider-jobcards"\]=(\{.+?\});', html)
    data = json.loads(data[0])
    return {
        "results": data["metaData"]["mosaicProviderJobCardsModel"]["results"],
        "meta": data["metaData"]["mosaicProviderJobCardsModel"]["tierSummaries"],
    }


async def scrape_search(client: httpx.AsyncClient, query: str, location: str, max_results: int = 50):
    def make_page_url(offset):
        parameters = {"q": query, "l": location, "filter": 0, "start": offset}
        return "https://www.indeed.com/jobs?" + urlencode(parameters)

    print(f"scraping first page of search: {query=}, {location=}")
    response_first_page = await client.get(make_page_url(0))
    data_first_page = parse_search_page(response_first_page.text)

    results = data_first_page["results"]
    total_results = sum(category["jobCount"] for category in data_first_page["meta"])
    # there's a page limit on indeed.com of 1000 results per search
    if total_results > max_results:
        total_results = max_results
    print(f"scraping remaining {total_results - 10 / 10} pages")
    other_pages = [make_page_url(offset) for offset in range(10, total_results + 10, 10)]
    for response in await asyncio.gather(*[client.get(url=url) for url in other_pages]):
        results.extend(parse_search_page(response.text))
    return results
import json
import re
from urllib.parse import urlencode

from scrapfly import ScrapflyClient, ScrapeConfig

scrapfly = ScrapflyClient(key="YOUR SCRAPFLY KEY")


def parse_search_page(html: str):
    data = re.findall(r'window.mosaic.providerData\["mosaic-provider-jobcards"\]=(\{.+?\});', html)
    data = json.loads(data[0])
    return {
        "results": data["metaData"]["mosaicProviderJobCardsModel"]["results"],
        "meta": data["metaData"]["mosaicProviderJobCardsModel"]["tierSummaries"],
    }


async def scrape_search(query: str, location: str, max_results: int = 50):
    def make_page_url(offset):
        parameters = {"q": query, "l": location, "filter": 0, "start": offset}
        return "https://www.indeed.com/jobs?" + urlencode(parameters)

    print(f"scraping first page of search: {query=}, {location=}")
    result_first_page = await scrapfly.async_scrape(ScrapeConfig(make_page_url(0), asp=True))
    data_first_page = parse_search_page(result_first_page.content)

    results = data_first_page["results"]
    total_results = sum(category["jobCount"] for category in data_first_page["meta"])
    # there's a page limit on indeed.com of 1000 results per search
    if total_results > max_results:
        total_results = max_results
    print(f"scraping remaining {total_results - 10 / 10} pages")
    other_pages = [
        ScrapeConfig(make_page_url(offset), asp=True) 
        for offset in range(10, total_results + 10, 10)
    ]
    async for result in scrapfly.concurrent_scrape(other_pages):
        results.extend(parse_search_page(result.content))
    return results

# example run
import asyncio
asyncio.run(scrape_search(query="python", location="texas"))
Run Code & Example Output
async def main():
    # we need to use browser-like headers to avoid being blocked instantly:
    HEADERS = {
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36",
        "Accept-Encoding": "gzip, deflate, br",
        "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
        "Accept-Language": "en-US,en;q=0.9,lt;q=0.8,et;q=0.7,de;q=0.6",
    }
    async with httpx.AsyncClient(headers=HEADERS) as client:
        search_data = await scrape_search(client, query="python", location="texas")
        print(json.dumps(search_data, indent=2))

asyncio.run(main())

This will result in search result data similar to:

[
    {
        "company": "Apple",
        "companyBrandingAttributes": {
            "headerImageUrl": "https://d2q79iu7y748jz.cloudfront.net/s/_headerimage/1960x400/ecdb4796986d27b654fe959e2fdac201",
            "logoUrl": "https://d2q79iu7y748jz.cloudfront.net/s/_squarelogo/256x256/86583e966849b2f081928769a6abdb09"
        },
        "companyIdEncrypted": "c1099851e9794854",
        "companyOverviewLink": "/cmp/Apple",
        "companyOverviewLinkCampaignId": "serp-linkcompanyname",
        "companyRating": 4.1,
        "companyReviewCount": 11193,
        "companyReviewLink": "/cmp/Apple/reviews",
        "companyReviewLinkCampaignId": "cmplinktst2",
        "displayTitle": "Software Quality Engineer, Apple Pay",
        "employerAssistEnabled": false,
        "employerResponsive": false,
        "encryptedFccompanyId": "6e7b40121fbb5e2f",
        "encryptedResultData": "VwIPTVJ1cTn5AN7Q-tSqGRXGNe2wB2UYx73qSczFnGU",
        "expired": false,
        "extractTrackingUrls": "https://jsv3.recruitics.com/partner/a51b8de1-f7bf-11e7-9edd-d951492604d9.gif?client=3427&rx_c=&rx_campaign=indeed16&rx_group=130795&rx_source=Indeed&job=200336736-2&rx_r=none&rx_ts=20220831T001748Z&rx_pre=1&indeed=sp",
        "extractedEntities": [],
        "fccompanyId": -1,
        "featuredCompanyAttributes": {},
        "featuredEmployer": false,
        "featuredEmployerCandidate": false,
        "feedId": 2772,
        "formattedLocation": "Austin, TX",
        "formattedRelativeTime": "Today",
        "hideMetaData": false,
        "hideSave": false,
        "highVolumeHiringModel": {
            "highVolumeHiring": false
        },
        "highlyRatedEmployer": false,
        "hiringEventJob": false,
        "indeedApplyEnabled": false,
        "indeedApplyable": false,
        "isJobSpotterJob": false,
        "isJobVisited": false,
        "isMobileThirdPartyApplyable": true,
        "isNoResumeJob": false,
        "isSubsidiaryJob": false,
        "jobCardRequirementsModel": {
            "additionalRequirementsCount": 0,
            "requirementsHeaderShown": false
        },
        "jobLocationCity": "Austin",
        "jobLocationState": "TX",
        "jobTypes": [],
        "jobkey": "5b47456ae8554711",
        "jsiEnabled": false,
        "locationCount": 0,
        "mobtk": "1gbpe4pcikib6800",
        "moreLocUrl": "",
        "newJob": true,
        "normTitle": "Software Quality Engineer",
        "openInterviewsInterviewsOnTheSpot": false,
        "openInterviewsJob": false,
        "openInterviewsOffersOnTheSpot": false,
        "openInterviewsPhoneJob": false,
        "overrideIndeedApplyText": true,
        "preciseLocationModel": {
            "obfuscateLocation": false,
            "overrideJCMPreciseLocationModel": true
        },
        "pubDate": 1661835600000,
        "redirectToThirdPartySite": false,
        "remoteLocation": false,
        "resumeMatch": false,
        "salarySnippet": {
            "salaryTextFormatted": false
        },
        "saved": false,
        "savedApplication": false,
        "showCommutePromo": false,
        "showEarlyApply": false,
        "showJobType": false,
        "showRelativeDate": true,
        "showSponsoredLabel": false,
        "showStrongerAppliedLabel": false,
        "smartFillEnabled": false,
        "snippet": "<ul style=\"list-style-type:circle;margin-top: 0px;margin-bottom: 0px;padding-left:20px;\"> \n <li style=\"margin-bottom:0px;\">At Apple, new ideas become extraordinary products, services, and customer experiences.</li>\n <li>We have the rare and rewarding opportunity to shape upcoming products\u2026</li>\n</ul>",
        "sourceId": 2700,
        "sponsored": true,
        "taxoAttributes": [],
        "taxoAttributesDisplayLimit": 5,
        "taxoLogAttributes": [],
        "taxonomyAttributes": [ { "attributes": [], "label": "job-types" }, "..."],
        "tier": {
            "matchedPreferences": {
                "longMatchedPreferences": [],
                "stringMatchedPreferences": []
            },
            "type": "DEFAULT"
        },
        "title": "Software Quality Engineer, Apple Pay",
        "translatedAttributes": [],
        "translatedCmiJobTags": [],
        "truncatedCompany": "Apple",
        "urgentlyHiring": false,
        "viewJobLink": "...",
        "vjFeaturedEmployerCandidate": false
    },
]

We've successfully scraped mountains of data with very few lines of Python code! Next, let's take a look at how to get the remainder of the job listing details (like full description) by scraping job pages.

Scraping Indeed Jobs

Our search results contain almost all job listing data except a few details, such as a complete job description. To scrape this, we need the job id, which is found in the jobkey field in our search results:

{
  "jobkey": "a82cf0bd2092efa3",
}

Using jobkey we can request the full job details page, and just like with the search; we can parse the embedded data instead of the HTML:

page source of indeed.com search page embedded data

We can see that all of the job and page information is hidden in the _initialData variable, which we can extract with a simple regular expression pattern:

Python
ScrapFly
import re
import json
import asyncio 
from typing import List

import httpx


def parse_job_page(html):
    """parse job data from job listing page"""
    data = re.findall(r"_initialData=(\{.+?\});", html)
    data = json.loads(data[0])
    return data["jobInfoWrapperModel"]["jobInfoModel"]


async def scrape_jobs(client: httpx.AsyncClient, job_keys: List[str]):
    """scrape job details from job page for given job keys"""
    urls = [f"https://www.indeed.com/m/basecamp/viewjob?viewtype=embedded&jk={job_key}" for job_key in job_keys]
    scraped = []
    for response in await asyncio.gather(*[client.get(url=url) for url in urls]):
        scraped.append(parse_job_page(response.text))
    return scraped
import re
import json
from typing import List

from scrapfly import ScrapeConfig, ScrapflyClient

scrapfly = ScrapflyClient(key="YOUR SCRAPFLY KEY")


def parse_job_page(html):
    """parse job data from job listing page"""
    data = re.findall(r"_initialData=(\{.+?\});", html)
    data = json.loads(data[0])
    return data["jobInfoWrapperModel"]["jobInfoModel"]


async def scrape_jobs(job_keys: List[str]):
    """scrape job details from job page for given job keys"""
    urls = [f"https://www.indeed.com/m/basecamp/viewjob?viewtype=embedded&jk={job_key}" for job_key in job_keys]
    to_scrape = [ScrapeConfig(url=url, asp=True) for url in urls]
    scraped = []
    async for result in scrapfly.concurrent_scrape(to_scrape):
        scraped.append(parse_job_page(result.content))
    return scraped
Run Code & Example Output
async def main():
    HEADERS = {
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36",
        "Accept-Encoding": "gzip, deflate, br",
        "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
        "Connection": "keep-alive",
        "Accept-Language": "en-US,en;q=0.9,lt;q=0.8,et;q=0.7,de;q=0.6",
    }
    async with httpx.AsyncClient(headers=HEADERS) as client:
        job_data = await scrape_jobs(client, ["a82cf0bd2092efa3"])
        print(job_data[0]['sanitizedJobDescription']['content'])
        print(job_data)

asyncio.run(main())

This will scrape results similar to:

[
    {
        "jobInfoHeaderModel": {
            "...",
            "companyName": "ExxonMobil",
            "companyOverviewLink": "https://www.indeed.com/cmp/Exxonmobil?campaignid=mobvjcmp&from=mobviewjob&tk=1gbpekba3is92800&fromjk=9dacdef3068a1d25",
            "companyReviewLink": "https://www.indeed.com/cmp/Exxonmobil/reviews?campaignid=mobvjcmp&cmpratingc=mobviewjob&from=mobviewjob&tk=1gbpekba3is92800&fromjk=9dacdef3068a1d25&jt=Geoscience+Technician",
            "companyReviewModel": {
                "companyName": "ExxonMobil",
                "desktopCompanyLink": "https://www.indeed.com/cmp/Exxonmobil/reviews?campaignid=viewjob&cmpratingc=mobviewjob&from=viewjob&tk=1gbpekba3is92800&fromjk=9dacdef3068a1d25&jt=Geoscience+Technician",
                "mobileCompanyLink": "https://www.indeed.com/cmp/Exxonmobil/reviews?campaignid=mobvjcmp&cmpratingc=mobviewjob&from=mobviewjob&tk=1gbpekba3is92800&fromjk=9dacdef3068a1d25&jt=Geoscience+Technician",
                "ratingsModel": {
                    "ariaContent": "3.9 out of 5 stars from 4,649 employee ratings",
                    "count": 4649,
                    "countContent": "4,649 reviews",
                    "descriptionContent": "Read what people are saying about working here.",
                    "rating": 3.9,
                    "showCount": true,
                    "showDescription": true,
                    "size": null
                }
            },
            "disableAcmeLink": false,
            "employerActivity": null,
            "employerResponsiveCardModel": null,
            "formattedLocation": "Spring, TX 77389",
            "hideRating": false,
            "isDesktopApplyButtonSticky": false,
            "isSimplifiedHeader": false,
            "jobTitle": "Geoscience Technician",
            "openCompanyLinksInNewTab": false,
            "parentCompanyName": null,
            "preciseLocationModel": null,
            "ratingsModel": null,
            "remoteWorkModel": null,
            "subtitle": "ExxonMobil - Spring, TX 77389",
            "tagModels": null,
            "viewJobDisplay": "DESKTOP_EMBEDDED"
        },
        "sanitizedJobDescription": {
            "content": "<p></p>\n<div>\n <div>\n  <div>\n   <div>\n    <h2 class='\"jobSectionHeader\"'><b>Education and Related Experience</b></h2>\n   </div>\n   <div>\n  ...",
            "contentKind": "HTML"
        },
        "viewJobDisplay": "DESKTOP_EMBEDDED"
    }
]

We should see the full job description printed out if we run this scraper.


With this last feature, our scraper is ready to go! However, if we run our scraper at scale we might get blocked and for that, let's take a look at how we can integrate ScrapFly to avoid being blocked.

Bypass Indeed Blocking with ScrapFly

Indeed.com is using anti-scraping protection to block web scraper traffic. To get around this, we can use ScrapFly web scraping API, which offers several powerful features:

illustration of scrapfly's middleware

For our Indeed scraper, we'll be using the Anti Scraping Protection Bypass feature via Scrapfly-sdk, which can be installed using pip console command:

$ pip install scrapfly-sdk

Now, we can enable Anti Scraping Protection bypass via asp=True flag:

from scrapfly import ScrapflyClient, ScrapeConfig

client = ScrapflyClient(key="YOUR_API_KEY")
result = client.scrape(ScrapeConfig(
    url="https://www.indeed.com/jobs?q=python&l=Texas",
    asp=True,
    # ^ enable Anti Scraping Protection
))
print(result.content)  # print page HTML

We can convert the rest of our scraper to ScrapFly SDK and avoid all blocking:

FAQ

Yes. The job data on Indeed.com is publicly available so it's perfectly legal to scrape. Take note though that some of the scraped material can be protected by copyright (such as images) etc.

Can Indeed be scraped using headless browsers such as Playwright?

Yes, but as covered in this article it's not necessary. Indeed pages are powered by a JSON API which can be scraped directly. This reduces the resource requirement for both the scraper and Indeed.com public data servers.

Is there a public API for Indeed.com?

No. As of the time of writing, there is no public API for Indeed.com job data. However, as indicated by this article Indeed.com can be easily scraped using Python!

Latest Indeed.com Scraper Code
https://github.com/scrapfly/scrapfly-scrapers/

Indeed Scraping Summary

In this short web scraping tutorial, we've looked at web scraping Indeed.com job listing search.
We built a search URL using custom search parameters and parsed job data from the embedded JSON data by using regular expressions. As a bonus, we also looked at scraping full job listing descriptions and how to avoid blocking using Scrapfly SDK.

Related Posts

How to Scrape Realestate.com.au Property Listing Data

We're taking yet another look at real estate websites. This time we're going down under! Realtestate.com.au is the biggest real estate portal in Australia and let's take a look at how to scrape it.

How to Scrape Immowelt.de Real Estate Data

Immowelt.de is a major real estate website in Germany and it's suprisingly easy to scrape. In this tutorial, we'll be using Python and hidden web data scraping technique to scrape real estate property data.

How to Scrape Homegate.ch Real Estate Property Data

For this scrape guide we'll be taking a look at another real estate website in Switzerland - Homegate. For this we'll be using hidden web data scraping and JSON parsing.