在Python中,读取爬虫结果通常有以下几种方法:
直接读取字符串
使用`requests`库获取网页内容后,可以直接读取字符串。
import requests
url = 'http://example.com'
response = requests.get(url)
html_string = response.text 获取的网页内容已经是字符串格式
使用BeautifulSoup解析HTML/XML
使用`BeautifulSoup`库解析HTML或XML文档,提取所需信息。
from bs4 import BeautifulSoup
html_string = '
First item