我需要一些幫助。我的輸出看起來不對。我怎樣才能正確追加dept,job_title,job_location的值。並且存在具有dept值的html標籤。我如何刪除這些標籤。python append()並刪除html標籤
我的代碼
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':諮詢,
'job_location': '芝加哥,IL'
'JOB_TITLE':SR顧問 - 中央'
每個變量的1個值。
請出示你的輸出... –
輸出將顯示,job_dept:所有部門,工作_location:所有位置,job_title:所有標題 –