Skip to content

Commit 56a33da

Browse files
committedOct 8, 2021
.
1 parent 57d1b8e commit 56a33da

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
 

Diff for: ‎indeed.py

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import requests
2+
from bs4 import BeautifulSoup
3+
4+
LIMIT = 50
5+
URL = f"https://www.indeed.com/jobs?q=Python&limit={LIMIT}"
6+
7+
def extract_indeed_pages():
8+
result = requests.get(URL)
9+
10+
soup = BeautifulSoup(result.text, "html.parser")
11+
12+
pagination = soup.find("div", {"class":"pagination"})
13+
14+
# pagination에서 링크만 모두 찾아줬음 div안에 링크들을 모음
15+
links = pagination.find_all('a')
16+
pages = []
17+
18+
for link in links[:-1]: #마지막 요소는 읽지 않겠다는 뜻
19+
pages.append(int(link.string)) #string -> integer 변환
20+
21+
max_page = pages[-1]
22+
return max_page
23+
24+
def extract_indeed_jobs(last_page):
25+
for page in range(last_page):
26+
res = requests.get(f"{URL}&start={page*LIMIT}")
27+
print(res.status_code)

0 commit comments

Comments
 (0)