【发布时间】:2017-03-02 23:29:15
【问题描述】:
我偶尔使用res.content 或res.text 来解析来自Requests 的响应。在我的用例中,我使用哪个选项似乎并不重要。
用.content 或.text 解析HTML 的主要区别是什么?例如:
import requests
from lxml import html
res = requests.get(...)
node = html.fromstring(res.content)
在上述情况下,我应该使用res.content 还是res.text?什么时候使用它们的一个好的经验法则是什么?
【问题讨论】:
标签: python python-requests lxml