今天尝试用beautifulsoup爬取信息,结果爬出的数据奇奇怪怪,突然出现空行,但是却不是空格(结果如下,同时附上代码),希望大佬能帮忙解决一下。
import requests
from bs4 import BeautifulSoup
with open('job.txt','w',encoding='utf-8',newline='')as f:
for i in range(3):
url='https://www.job001.cn/jobs?pageNo='+str(i)
headers={'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36 Edg/90.0.818.62'}
r=requests.get(url=url,headers=headers)
r.encoding='utf-8'
html=r.text
soup=BeautifulSoup(html,'html.parser')
tbody=soup.find_all(attrs={'class':'jobsList'})
for items in tbody:
job=items.find('a',class_="jobNameCon").string
salary=items.find('span',class_