请用python代码写一个爬取网页文字信息的代码
时间: 2024-05-25 16:17:10 浏览: 211
python 爬取网页
import requests
from bs4 import BeautifulSoup
url = "https://www.example.com" # 需要爬取的网页链接
response = requests.get(url)
soup = BeautifulSoup(response.text, "html.parser")
text = soup.get_text() # 获取网页中的文字信息
print(text)
阅读全文