from requests import get
from bs4 import BeautifulSoup
base_url = "https://www.jobkorea.co.kr/Search/?stext="
search_term = "python"
response = get(f"{base_url}+{search_term}")
if response.status_code != 200:
print("cant request")
else:
results = []
soup = BeautifulSoup(response.text, "html.parser")
job_list = soup.find("div", class_="list-default")
jobs = job_list.find("ul", class_="clear")
# recursive tag를 찾을 때에는 find_all을 하면 된다.
job = jobs.find_all("li", class_="list-post")
for job_section in job:
post = job_section.find_all("div", class_="post")
for job_section in post:
# company name
post_list = job_section.find("div", class_="post-list-corp")
company_name = post_list.find("a")
company = company_name["title"]
# link
link = company_name["href"]
# company position
post_list_info = job_section.find("div", class_="post-list-info")
title_name = post_list_info.find("a")
title = title_name["title"]
# location
location_name = post_list_info.find("p", class_="option")
location = location_name.find("span", class_="loc long")
# position
position = location_name.find("span", class_="exp")
job_data = {
"company": company,
"position": title,
"region": location.string,
"link": f"https://www.jobkorea.co.kr/Search/?stext=+{link}",
# "title": title.string
}
results.append(job_data)
print(results)
'Programming > python' 카테고리의 다른 글
[python] Day 26 (0) | 2023.03.05 |
---|---|
[python] 데이터 스크랩 연습 (0) | 2023.03.04 |
[Python, web scrapper] 데이터 수집 연습 (0) | 2023.03.03 |
[python] Day 23 (1) | 2023.03.01 |
[python] 파이썬 연습 (0) | 2023.02.28 |