【发布时间】:2020-04-15 15:45:39
【问题描述】:
我正在尝试为美国的工作搜索 Indeed。我有以下代码
url = "https://www.indeed.com/jobs?q=&l=United+states"
headers = {'Indeed': 'Mozilla/5.0'}
page = requests.get(url, headers=headers)
soup1 = BeautifulSoup(page.text, 'html.parser')
location=[]
title = []
for item in soup1.findAll('div', {'class': 'location accessible-contrast-color-location'}):
result = [item.get_text(strip=True, separator=" ")]
location.append(result)
for item in soup1.findAll('h2', {'class': 'title'}):
result = [item.get_text(strip=True, separator=" ")]
title.append(result)
当我打印位置和标题时,结果与网站上实际显示的不同。
print(title[1]) should give **Special Agent (FBI)**
where as it gives **Amazon Prime Shopper**
你能告诉我我哪里出错了
【问题讨论】:
标签: python web-scraping beautifulsoup