【发布时间】:2021-01-21 00:22:32
【问题描述】:
我正在使用招聘列表数据进行网络抓取项目。我在找出从 html 标签中提取内容的最佳方法时遇到了一些麻烦。下面的代码输出如下:
修复数据分析师/h3>>
我只需要剥离 html,以便输出只是“补救数据分析师”。我知道这很简单。
脚本:
import pandas as pd
from bs4 import BeautifulSoup
import requests
import re
url = requests.get('https://au.jora.com/j?sp=homepage&q=analytics&l=Sydney+NSW')
soup = BeautifulSoup(url.content, 'html.parser')
containers = soup.find_all(class_='job-item')
for c in containers:
try:
print(c.find_all(class_='job-title'))
except:
print('n/a')
【问题讨论】:
标签: html python-3.x beautifulsoup