Package: linkedin-jobs-scraper
linkedin-jobs-scraperScrape public available jobs on Linkedin using headless browser.
For each job, the following fields are extracted:job_id,link,apply_link,title,company,company_link,company_img_link,place,description,description_html,date,insights.It's also available an equivalentnpm package.⚠DISCLAIMERThis package is meant for personal or educational use only. All the data extracted by
using this package is publicly available on the LinkedIn website and it remains owned by LinkedIn company.
I am not responsible in any way for the inappropriate use of data extracted through this library.Table of ContentsRequirementsInstallationUsageAnonymous vs authenticated sessionRate limitingProxy modeFiltersCompany filterLoggingSponsorsLicenseRequirementsChromeorChromiumChromedriver: latest version tested is119.0.6045.105(Dockerfile)Python >= 3.7InstallationInstall package:pipinstalllinkedin-jobs-scraperUsageimportloggingfromlinkedin_jobs_scraperimportLinkedinScraperfromlinkedin_jobs_scraper.eventsimportEvents,EventData,EventMetricsfromlinkedin_jobs_scraper.queryimportQuery,QueryOptions,QueryFiltersfromlinkedin_jobs_scraper.filtersimportRelevanceFilters,TimeFilters,TypeFilters,ExperienceLevelFilters,\OnSiteOrRemoteFilters# Change root logger level (default is WARN)logging.basicConfig(level=logging.INFO)# Fired once for each successfully processed jobdefon_data(data:EventData):print('[ON_DATA]',data.title,data.company,data.company_link,data.date,data.link,data.insights,len(data.description))# Fired once for each page (25 jobs)defon_metrics(metrics:EventMetrics):print('[ON_METRICS]',str(metrics))defon_error(error):print('[ON_ERROR]',error)defon_end():print('[ON_END]')scraper=LinkedinScraper(chrome_executable_path=None,# Custom Chrome executable path (e.g. /foo/bar/bin/chromedriver)chrome_binary_location=None,# Custom path to Chrome/Chromium binary (e.g. /foo/bar/chrome-mac/Chromium.app/Contents/MacOS/Chromium)chrome_options=None,# Custom Chrome options hereheadless=True,# Overrides headless mode only if chrome_options is Nonemax_workers=1,# How many threads will be spawned to run queries concurrently (one Chrome driver for each thread)slow_mo=0.5,# Slow down the scraper to avoid 'Too many requests 429' errors (in seconds)page_load_timeout=40# Page load timeout (in seconds))# Add event listenersscraper.on(Events.DATA,on_data)scraper.on(Events.ERROR,on_error)scraper.on(Events.END,on_end)queries=[Query(options=QueryOptions(limit=27# Limit the number of jobs to scrape.)),Query(query='Engineer',options=QueryOptions(locations=['United States','Europe'],apply_link=True,# Try to extract apply link (easy applies are skipped). If set to True, scraping is slower because an additional page must be navigated. Default to False.skip_promoted_jobs=True,# Skip promoted jobs. Default to False.page_offset=2,# How many pages to skiplimit=5,filters=QueryFilters(company_jobs_url='https://www.linkedin.com/jobs/search/?f_C=1441%2C17876832%2C791962%2C2374003%2C18950635%2C16140%2C10440912&geoId=92000000',# Filter by companies.relevance=RelevanceFilters.RECENT,time=TimeFilters.MONTH,type=[TypeFilters.FULL_TIME,TypeFilters.INTERNSHIP],on_site_or_remote=[OnSiteOrRemoteFilters.REMOTE],experience=[ExperienceLevelFilters.MID_SENIOR]))),]scraper.run(queries)Anonymous vs authenticated session⚠ WARNING: due to lack of time, anonymous session strategy is no longer maintained. If someone wants to keep
support for this feature and become a project maintainer, please be free to pm me.By default the scraper will run in anonymous mode (no authentication required). In some environments (e.g. AWS or Heroku)
this may be not possible though. You may face the following error message:Scraper failed to run in anonymous mode, authentication may be necessary for this environment.In that case the only option available is to run using an authenticated session. These are the steps required:Login to LinkedIn using an account of your choice.Open Chrome developer tools:Go to tabApplication, then from left panel selectStorage->Cookies->https://www.linkedin.com. In the
main view locate row with nameli_atand copy content from the columnValue.Set the environment variableLI_AT_COOKIEwith the value obtained in step 3, then run your application as normal.
Example:LI_AT_COOKIE=<yourli_atcookievaluehere>pythonyour_app.pyRate limitingYou may experience failing requests with the status code 429. This means you are sending too many request to the server
and they are being throttled. You can overcome this by:Trying a higher value forslow_moparameter (this will slow down scraper execution).Reducing the value ofmax_workersto limit concurrency. I recommend to use no more than one worker in authenticated
mode.The right value forslow_moparameter largely depends on rate-limiting settings on Linkedin servers (and this can
vary over time). For the time being, I suggest a value of at least1.3in anonymous mode and0.5in authenticated
mode.FiltersIt is possible to customize queries with the following filters:RELEVANCE:RELEVANTRECENTTIME:DAYWEEKMONTHANYTYPE:FULL_TIMEPART_TIMETEMPORARYCONTRACTEXPERIENCE LEVEL:INTERNSHIPENTRY_LEVELASSOCIATEMID_SENIORDIRECTORON SITE OR REMOTE:ON_SITEREMOTEHYBRIDINDUSTRY:AIRLINES_AVIATIONBANKINGCIVIL_ENGINEERINGCOMPUTER_GAMESENVIRONMENTAL_SERVICESELECTRONIC_MANUFACTURINGFINANCIAL_SERVICESINFORMATION_SERVICESINVESTMENT_BANKINGINVESTMENT_MANAGEMENTIT_SERVICESLEGAL_SERVICESMOTOR_VEHICLESOIL_GASSOFTWARE_DEVELOPMENTSTAFFING_RECRUITINGTECHNOLOGY_INTERNETCOMPANY:See belowSee the following example for more details:fromlinkedin_jobs_scraper.queryimportQuery,QueryOptions,QueryFiltersfromlinkedin_jobs_scraper.filtersimportRelevanceFilters,TimeFilters,TypeFilters,ExperienceLevelFilters,\OnSiteOrRemoteFilters,IndustryFiltersquery=Query(query='Engineer',options=QueryOptions(locations=['United States'],apply_link=True,skip_promoted_jobs=True,limit=5,filters=QueryFilters(relevance=RelevanceFilters.RECENT,time=TimeFilters.MONTH,type=[TypeFilters.FULL_TIME,TypeFilters.INTERNSHIP],experience=[ExperienceLevelFilters.INTERNSHIP,ExperienceLevelFilters.MID_SENIOR],on_site_or_remote=[OnSiteOrRemoteFilters.REMOTE],industry=[IndustryFilters.IT_SERVICES],)))Industry FilterYou will probably need to add the industry filter to the IndustryFilters class in filters.pyTo find the numeric code for the industry:Perform the search on LinkedIn in a browser, with the industry filter applied.The numeric code is in the URL, immediately afterf_I. For example URLhttps://www.linkedin.com/jobs/search/?currentJobId=3661007408&distance=25&f_E=3%2C4&f_I=43%2C46%2C41%2C45&f_JT=F%2CC&geoId=102257491&keywords=Product%20Owner&refresh=truecontains textf_I=43%2C46%2C41%2C45indicating a filter is applied on industry codes 43, 46, 41 and 45.Company FilterIt is also possible to filter by company using the public company jobs url on LinkedIn. To find this url you have to:Login to LinkedIn using an account of your choice.Go to the LinkedIn page of the company you are interested in (e.g.https://www.linkedin.com/company/google).Click onjobsfrom the left menu.Scroll down and locateSee all jobsorSee jobsbutton.Right click and copy link address (or navigate the link and copy it from the address bar).Paste the link address in code as follows:query=Query(options=QueryOptions(filters=QueryFilters(# Paste link belowcompany_jobs_url='https://www.linkedin.com/jobs/search/?f_C=1441%2C17876832%2C791962%2C2374003%2C18950635%2C16140%2C10440912&geoId=92000000',)))LoggingPackage logger can be retrieved using namespaceli:scraper. Default level isINFO.
It is possible to change logger level using environment variableLOG_LEVELor in code:importlogging# Change root logger level (default is WARN)logging.basicConfig(level=logging.DEBUG)# Change package logger levellogging.getLogger('li:scraper').setLevel(logging.DEBUG)# Optional: change level to other loggerslogging.getLogger('urllib3').setLevel(logging.WARN)logging.getLogger('selenium').setLevel(logging.WARN)SponsorsProxycurl APIsScrape public LinkedIn profile data at scale with Proxycurl APIs.Scraping Public profiles are battle tested in court in HiQ VS LinkedIn case.GDPR, CCPA, SOC2 compliant.High rate Limit - 300 requests/minute Fast APIs respond in ~2s.Fresh data - 88% of data is scraped real-time, other 12% are not older than 29 days.High accuracy.Tons of data points returned per profile.Built for developers, by developers.LicenseMIT LicenseIf you like the project and want to contribute you candonate something here!