【发布时间】:2021-10-29 18:14:31
【问题描述】:
import pandas as pd
from bs4 import BeautifulSoup
import requests
import os
url = 'https://fr.indeed.com/jobs?q=data%20anlayst&l=france'
#grabbing page content and parsing it into html
def data_grabber(url):
page = requests.get(url)
html = page.text
soup = BeautifulSoup(html, 'html.parser')
job_soup = soup.find_all('div', {"class":"job_seen_beacon"})
return job_soup
def job_title(url):
titles = data_grabber(url)
for title in titles:
t = title.find_all('tbody')
return t
这是我的源代码,我在 jupyter notebook 中对其进行了测试,以确保我的功能正常工作,但我遇到了一个小障碍。我的第一个函数中的 html 汤完美运行。它确实获取了所有信息,尤其是 job_seen_beacon 类。
Mr job_title 函数是错误的,因为它只输出它找到的第一个 'tbody' 类。 refer to image here, I don't have enough points on stack
而对于我的 data_grabber,它会返回每个 job_seen_beacon。 If you were able to scroll, you would easily see the multiple job_seen_beacon's.
我显然遗漏了一些东西,但我看不到它,有什么想法吗?
【问题讨论】:
标签: python function web-scraping beautifulsoup