도움이 필요합니다. 내 출력이 틀린 것 같습니다. dept, job_title, job_location의 값을 올바르게 추가하려면 어떻게해야합니까? 그리고 dept의 값을 가진 html 태그가 있습니다. 어떻게 이러한 태그를 제거 할 수 있습니까? 시니어 :python append() 및 html 태그를 제거하십시오.
'JOB_TITLE' 'IL 시카고', 컨설팅
'job_location을'
내 코드
response = requests.get("http://hortonworks.com/careers/open-positions/")
soup = BeautifulSoup(response.text, "html.parser")
jobs = []
div_main = soup.select("div#careers_list")
for div in div_main:
dept = div.find_all("h4", class_="department_title")
div_career = div. find_all("div", class_="career")
title = []
location = []
for dv in div_career:
job_title = dv.find("div", class_="title").get_text().strip()
title.append(job_title)
job_location = dv.find("div", class_="location").get_text().strip()
location.append(job_location)
job = {
"job_location": location,
"job_title": title,
"job_dept": dept
}
jobs.append(job)
pprint(jobs)
그것은
{ 'job_dept'과 같아야합니다 컨설턴트 - 중부 '
각 변수에 대해 1 개의 값.
는 당신이 얻을 출력을 보여주십시오 –
출력 ... job_dept : 모든 부서, 작업 _ 위치 : 모든 위치, job_title : 전체 제목 –