mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-07-05 17:34:49 +08:00
Lukazlim: Replace dependency requests
with httpx
(#12744)
* Replace dependency `requests` with `httpx` Fixes #12742 Signed-off-by: Lim, Lukaz Wei Hwang <lukaz.wei.hwang.lim@intel.com> * updating DIRECTORY.md * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Signed-off-by: Lim, Lukaz Wei Hwang <lukaz.wei.hwang.lim@intel.com> Co-authored-by: Lim, Lukaz Wei Hwang <lukaz.wei.hwang.lim@intel.com> Co-authored-by: cclauss <cclauss@users.noreply.github.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
@ -2,20 +2,26 @@
|
||||
Scraping jobs given job title and location from indeed website
|
||||
"""
|
||||
|
||||
# /// script
|
||||
# requires-python = ">=3.13"
|
||||
# dependencies = [
|
||||
# "beautifulsoup4",
|
||||
# "httpx",
|
||||
# ]
|
||||
# ///
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from collections.abc import Generator
|
||||
|
||||
import requests
|
||||
import httpx
|
||||
from bs4 import BeautifulSoup
|
||||
|
||||
url = "https://www.indeed.co.in/jobs?q=mobile+app+development&l="
|
||||
|
||||
|
||||
def fetch_jobs(location: str = "mumbai") -> Generator[tuple[str, str]]:
|
||||
soup = BeautifulSoup(
|
||||
requests.get(url + location, timeout=10).content, "html.parser"
|
||||
)
|
||||
soup = BeautifulSoup(httpx.get(url + location, timeout=10).content, "html.parser")
|
||||
# This attribute finds out all the specifics listed in a job
|
||||
for job in soup.find_all("div", attrs={"data-tn-component": "organicJob"}):
|
||||
job_title = job.find("a", attrs={"data-tn-element": "jobTitle"}).text.strip()
|
||||
|
Reference in New Issue
Block a user