最近初学python,进展到网络爬虫部分,尝试自己写一下查票,结果遇到了麻烦
import requests
url = 'https://kyfw.12306.cn/otn/leftTicket/queryZ?' \
'leftTicketDTO.train_date=2020-02-01&' \
'leftTicketDTO.from_station=SHH&' \
'leftTicketDTO.to_station=BJP&purpose_codes=ADULT'
result=requests.get(url)
print(result.json())
出现的问题如下:
Traceback (most recent call last):
File "D:/Files/check tickets/123.py", line 7, in <module>
print(result.json())
File "D:\Files\python3\lib\site-packages\requests\models.py", line 897, in json
return complexjson.loads(self.text, **kwargs)
File "D:\Files\python3\lib\json\__init__.py", line 357, in loads
return _default_decoder.decode(s)
File "D:\Files\python3\lib\json\decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "D:\Files\python3\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)
不知如何解决,求解答,谢谢!