来自Py的一个小问题。
第一次学习爬虫,下面这个代码运行不了
有木有人可以教教我啊
import requests as re
url = 'https://movie.douban.com/j/chart/top_list?'
header = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.89 Safari/537.36 SLBrowser/7.0.0.9231 SLBChan/11'
}
params = {
'type': '17',
'interval_id': '100:90',
'action': '',
'start': '0',
'limit': '1'
}
response = re.get(url=url, headers=header, params=params)
page_text = response.json()
for item in page_text:
name = item['title']
time = item['release_date']
print(name, time)
倒数第六行代码里出现了问题也不知道为什么
运行就出现下面错误,一直搞不明白。
Traceback (most recent call last):
File "C:/Users/lenovo/PycharmProjects/pythonProject1/豆瓣爬取.py", line 16, in <module>
page_text = response.json()
File "C:\Users\lenovo\PycharmProjects\pythonProject1\venv\lib\site-packages\requests\models.py", line 910, in json
return complexjson.loads(self.text, **kwargs)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.2800.0_x64__qbz5n2kfra8p0\lib\json\__init__.py", line 357, in loads
return _default_decoder.decode(s)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.2800.0_x64__qbz5n2kfra8p0\lib\json\decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.2800.0_x64__qbz5n2kfra8p0\lib\json\decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
感激不尽