我一直在尝试提取网页的数据丰富节点。有没有办法从网页中提取文本
import requests
import bs4
from bs4 import BeautifulSoup
import urllib2
url = "http://www.amazon.in"
r = requests.get(url)
html = BeautifulSoup(r.content)
print html.title.text
我可以打印网页的标题,请你帮我提取网页中的文字(只有文字)。
提前致谢
答案 0 :(得分:1)
试试这个
import requests
import bs4
from bs4 import BeautifulSoup
import urllib2
url = "http://www.amazon.in"
r = requests.get(url)
html = BeautifulSoup(r.content, "html.parser")
print html.get_text()