-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
34 lines (26 loc) · 1 KB
/
main.py
File metadata and controls
34 lines (26 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import requests
from bs4 import BeautifulSoup
URL = "https://realpython.github.io/fake-jobs/"
page = requests.get(URL)
soup = BeautifulSoup(page.content, "html.parser")
results = soup.find(id="ResultsContainer")
job_elements = results.find_all("div", class_="card-content")
# for job_element in job_elements:
# title_element = job_element.find("h2", class_="title")
# company_element = job_element.find("h3", class_="company")
# location_element = job_element.find("p", class_="location")
# print(title_element.text)
# print(company_element.text)
# print(location_element.text)
# print()
python_jobs = results.find_all("h2", string=lambda text : "python" in text.lower())
python_job_elements = [
h2_element.parent.parent.parent for h2_element in python_jobs
]
for job_element in python_job_elements:
# -- snip --
links = job_element.find_all("a")
for link in links:
link_url = link["href"]
print(f"Apply here: {link_url}\n")
# print(results.prettify())