Python 简单爬虫

from bs4 import BeautifulSoup
import requests

if name==“main”:
target=“https://mbd.baidu.com/newspage/data/landingsuper?context=%7B%22nid%22%3A%22news_9433710732874198416%22%7D&n_type=0&p_from=1”
bf=BeautifulSoup(requests.get(target).text)
textes=bf.find_all(‘span’,class_=“bjh-p”)

print(textes[0].text.replace('\xa0' * 8, '\n\n'))
print(textes[1].text.replace('\xa0' * 8, '\n\n'))
print(textes[2].text.replace('\xa0' * 8, '\n\n'))
上一篇:SpringSession


下一篇:python使用beautifulsoup报错You're probably treating a list of items like a single item. Did you cal