【发布时间】:2021-05-18 19:13:53
【问题描述】:
我想抓取网页内容并清理格式
from bs4 import BeautifulSoup
import urllib.request
import urllib.parse
import lxml
url='https://en.wikipedia.org/wiki/Deep_learning'
page=urllib.request.urlopen(url)
soup=BeautifulSoup(page,"lxml")
fetched_text=' '.join(map(lambda p: p.text.soup.find_all('p'),soup))
此代码最初是从这样的 youtube 教程中找到的:
fetched_text=' '.join(map(lambda p: p.text.soup.find_all('p')))
谁能帮帮我?
【问题讨论】:
-
[x.text for x in soup.select('p')]
标签: python beautifulsoup urllib