Skip to content

Commit d8dae8c

Browse files
committed
so
1 parent 03d6119 commit d8dae8c

File tree

5 files changed

+94
-11
lines changed

5 files changed

+94
-11
lines changed

__pycache__/so.cpython-38.pyc

618 Bytes
Binary file not shown.

main.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
from indeed import get_jobs as get_indeed_jobs
2-
# from so import get_jobs as get_so_jobs
2+
from so import get_jobs as get_so_jobs
33
from save import save_file
44

5-
indeed_jobs = get_indeed_jobs()
5+
# indeed_jobs = get_indeed_jobs()
66
# so_jobs = get_so_jobs()
77

8-
jobs = indeed_jobs
8+
# jobs = indeed_jobs + so_jobs
99

10-
save_file(jobs)
10+
# save_file(jobs)

poetry.lock

Lines changed: 64 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@ python = "^3.7"
1313
requests = "^2.23"
1414
beautifulsoup4 = "^4.9"
1515
babel = "^2.8"
16+
flask = "^1.1"
1617
[tool.poetry.dev-dependencies]

so.py

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,35 @@
11
import requests
22
from bs4 import BeautifulSoup
33

4-
URL = f"https://stackoverflow.com/jobs"
4+
URL = f"https://stackoverflow.com/jobs?q=python"
55

66

77
def get_last_page():
8-
result = requests.get(URL)
9-
soup = BeautifulSoup(result.text, "html.parser")
10-
pages = soup.find("div", {"class": "s-pagination"}).find_all("a")
11-
print(pages)
8+
result = requests.get(URL)
9+
soup = BeautifulSoup(result.text, "html.parser")
10+
pages = soup.find("div", {"class": "s-pagination"}).find_all("a")
11+
last_page = pages[-2].get_text(strip=true)
12+
return int(last_page)
13+
14+
15+
def extract_job(html):
16+
title = html.find("div", {"class": "grid--cell fl1 "}).find("a")["title"]
17+
print(title)
18+
19+
20+
def extract_jobs(last_page):
21+
jobs = []
22+
for page in range(last_page):
23+
result = requests.get(f"{URL}&pg={page+1}")
24+
soup = BeautifulSoup(result.text, "html.parser")
25+
results = soup.find_all("div", {"class": "grid--cell fl1 "})
26+
for result in results:
27+
job = extract_jobs(result)
28+
job.append(job)
29+
return jobs
1230

1331

1432
def get_jobs():
1533
last_page = get_last_page()
16-
return []
34+
jobs = extract_jobs(last_page)
35+
return jobs

0 commit comments

Comments
 (0)