# -*- coding:utf-8 -*-
import time
import requests
headers={
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.119 Safari/537.36'
}
response=requests.get('http://maoyan.com/board/4?offset=10',headers=headers)
html=response.text
print(response.status_code)
print(html)
例如以上代码,在get方法中去掉headers,在response.text时候出现错误,加上则正常。估计是编码原因引起的。