import requests
from bs4 import BeautifulSoup
from pprint import pp
def main(url):
r = requests.get(url)
soup = BeautifulSoup(r.text, 'lxml')
x = [x.get_text(strip=True, separator=" ") for x in soup.select(
'span[data-parade-type="promoarea"] .figure_block ~ p')]
goal = [i for i in x if i[0].isdigit()]
pp(goal)
main('https://parade.com/937586/parade/life-quotes/')
Note, If you are using Windows machine, DO NOT forget to include from_encoding= equal to the encoding used by your sys.
参考:https://www.crummy.com/software/BeautifulSoup/bs4/doc/#encodings
否则:
相关问题 更多 >
编程相关推荐