我偶尔会使用res.content
或res.text
解析来自请求的响应.在我使用的用例中,我使用的选项似乎并不重要.
用.content
或解析HTML的主要区别是什么.text
?例如:
import requests
from lxml import html
res = requests.get(...)
node = html.fromstring(res.content)
Run Code Online (Sandbox Code Playgroud)
在上述情况下,我应该使用res.content
还是res.text
?何时使用每种方法有什么好的经验法则?