已有184人关注
关于第十四章“快手爬票”项目 请求地址的更新
发表在Python图书答疑 2018-10-16 《零基础学Python》第14章 网络爬虫开发
是否精华
版块置顶:

《零基础学Python》第14章——快手爬票项目由于查询功能的请求地址更新 (12306官网的查询地址更换)为了让大家更好的运行程序,我们已经将更改后的资源在图书网盘连接中更新,大家可以通过网盘链接下载更新后的资源。

也可以下载本帖下的附件。

check tickets.rar


2018-10-16 17:12:36编辑
分享到:
精彩评论 34
MrTang
学分:138 LV3
2020-04-19
21L
import requests

url = 'https://kyfw.12306.cn/otn/leftTicket/query?leftTicketDTO.train_date=2020-04-19&leftTicketDTO.from_station=BJP&leftTicketDTO.to_station=SHH&purpose_codes=ADULT'

response = requests.get(url)
print(response)
response.json()

图片.png

MrTang
学分:138 LV3
2020-04-19
22L

MrTang 发表于2020-04-19 15:06

import requests

url = 'https://kyfw.12306.cn/otn/leftTicket/query?leftTicketDTO.train_date=2020-04-19&leftTicketDTO.from_station=BJP&leftTicketDTO.to_station=SHH&purpose_codes=ADULT'

response = requests.get(url)
print(response)
response.json()

图片.png

response.json() 调用报错 ,不知道啥原因 ,,导致这个不能往下进行,,望老师看到疑问 帮忙解答以下


MrTang
学分:138 LV3
2020-04-19
23L

MrTang 发表于2020-04-19 15:08

response.json() 调用报错 ,不知道啥原因 ,,导致这个不能往下进行,,望老师看到疑问 帮忙解答以下


补充以下 ,,下载课本的 源码程序执行 也是报同样的错误:

图片.png

MrTang
学分:138 LV3
2020-04-20
24L

宝宝天龙 发表于2019-11-11 19:43

我下载的也出问题了,原代码:

response=requests.get(url)

res = response.json()

问题代码为:

JSONDecoderError:Expecting value: line 1 column 1 (char 0)

我也有一样的问题

团团圆圆
学分:37 LV2
2020-04-26
25L

官方新上传的爬虫程序只是加了一个伪随机头,不过12306还是会封。解决办法,一是利用代理IP,二是将最新的cookies写入到代码中,三是利用其它模块重写方法。

很多网友提出Process finished with exit code -1073740791 (0xC0000409),这是因为没有爬取到数据,即data为空。

建议:官方程序时间差计算的代码有bug,不支持跨年,如19年1月减18年12月会报错,应该用datetime.datetime.fromtimestamp()替换。

附:本人已学完《零基础学python》全部内容,成功调试出书中全部代码,存在的bug已向管理员提出修改建议。初学者可加我微信共同学习交流!

微信 13661017741。


团团圆圆
学分:37 LV2
2020-05-01
26L

且听风吟_1544946537 发表于2018-12-16 15:57

Process finished with exit code -1073740791 (0xC0000409) 这个错误是怎么回事?

这是没有爬取到数据,即data为空,查看请求地址是否正确,另外还要加上请求头,两者缺一不可,有疑问加我微信

13661017741

13887180086
学分:7 LV1
2021-03-21
27L

《python项目开发案例集锦》11.5.3查询所有火车票信息  的query()方法中,result=response.json()语句运行时报错json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)。请老师给予指导。

json运行错误.png


Administrator
学分:1180 LV8
TA的每日心情
东指即为天涯
2017-04-30 20:46:44
2021-03-22
28L

13887180086 发表于2021-03-21 15:58

《python项目开发案例集锦》11.5.3查询所有火车票信息  的query()方法中,result=response.json()语句运行时报错json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)。请老师给予指导。

json运行错误.png


发到python的版块,会有专门的技术老师给你解答

13887180086
学分:7 LV1
2021-03-23
29L

Administrator 发表于2021-03-22 14:30

发到python的版块,会有专门的技术老师给你解答

已经发了三天了,根本没有人答疑。

wacent
学分:16 LV2
2021-08-07
30L

我发现

response = requests.get(url)

获取的response不能用json()来获取结果。相同的url通过google获取的结果为:

{"httpstatus":200,"data":{"result":["8%2FyS5zgR4C5y6bD2SOs7au4%2Fe7596F3k4UnG1O7f%2F7Ky1%2B6twpR6gw27NnUlG8UaQBl%2BOO83dunC%0ARN9a3KRvC8wWOv%2BkcIN%2FTElNzBnDos3hfp1xJ1CFmm8mzEhiEgIie98Qd%2Ba4NetwQUMRJh0dYz1Q%0AXAU%2FabsgiupHQfqa4H40KWqrSX0qQBu7VweecNVa%2FC99BiikWexbN%2FaDIIq7dwQDAMZmqcbPUbKV%0AmdSsS2cr1DtAQ1dLk9pFaVbj8Y1WXZUr%2BMMkq4vuIJiC8qwIy10actQYHPk6x1XHIZCn%2BZefcfYv%0A|预订|240000G13320|G133|VNP|SHH|VNP|SHH|11:49|18:07|06:18|Y|1QwBujd89e5%2FFyzFwbhWBXy%2F1Tlc2%2FHaJwQsLezyuKHJvBPg|20210807|3|P3|01|13|1|0|||||||||||有|有|6||O0M090|OM9|1|0||O060400021M1012500219217200006|0|||||1|#0#0|","PJxd864NiRsk6WxDZKsSqInhtSfDP8WNy1agelsX079LcqoxtU64RcF3crTzNPz3y1bviretSDb0%0A4YvD4nUpKwFw6kpaloRCqu1xcaSKF1Uf96oLUJ6xx9pm5YmZaKw8phuGptrXAPGLH40lylVu4gD%2F%0AlFeoulDb1r%2BPlKaURHlvpKwqzSIeBfR75SH5HZcSaYftrE%2FonTiySAiZD1IsTr5dKSruHngv2yO7%0AlRjTh%2F6ZHVA1We%2FfOkU9pJ9KHk8zP%2Bb%2BjPMEDqerHWRSuDSOWrhQIxbW4akH8aGsB5tK%2FWc18F%2Bs%0AAnsM9IoCUqo%3D|预订|2400000G110N|G11|VNP|AOH|VNP|AOH|12:00|16:38|04:38|Y|EfYTtUxXyP4JWA5wd%2FrWmo%2BCl1b%2Fn0LYjaIW2JR5NoC2VCMC|20210807|3|P2|01|05|1|0|||||||||||有|有|11||O090M0|O9M|1|0||O0626000219231800011M103500021|0|||||1|5#1#Q03|O062600021","2DIiNta238UDG19B46P8J6wC4uXm4NaFStTyS8SxhsVl14cKtmHr5PjRFb6EdZusCKc2FCrumMnb%0AGxnn%2FLaAj3MnPZCE%2B2UXSKcZc%2B3xEe5UB8gbxpI5CcXSkhHg4f19Cp4PHZZTMG4AI2qWYceiwp%2FE%0A%2BBZXd7Kju9L3M2Bu2sLR67xAnXr%2BbgYJSL3%2BtR42iAYNgnNKuB3e9y2308RBWvWsTzkBTPi4MTdZ%0AqFIKTC8NezjhwuMiOpCb4VzW%2B8OStXTCToDz0NuJGxUJjXVvdkI7FX9VGnaGgTnnNOtW2wYDwPVd%0ABAcSjQpV6vg%3D|预订|240000G1350H|G135|VNP|AOH|VNP|AOH|12:12|18:21|06:09|Y|jk5ri0yiBOHmllvPt3quMnbEyZjIeb37P%2BF43EUitS0mPETa|20210807|3|P4|01|13|1|0|||||||||||有|7|无||M090O0|M9O|1|1||M0969000079199800000O057600021|0|||||1|#0#0|","HMnvctWx0MBERQ217vE6DwV0Yt9X3Im6aZ696yOEy7IEL1qlhorZbiJoMBXi4I%2FSEonGlPqnnRCw%0AMtvxSbXVLz91iQjvdYhF%2FPE9luYUbbk0wMlI8axtrKvnJqfvOiPNBcZemx1w%2FtyW9afSO3zgBlVl%0AMbvWMIm2BkCnKbf2IAUfx1w6IG8RIp%2F31lE3jKkqyxLn0PTQ8nwOVvPwC2ue5Ko5D6WlCYONVW5P%0AB9oQdB3NMD9AfIbE4Zoge0mwRRuKpJ4Mp1vDLQ7izseUvptmhSFWllXq7gMVBkZ5o8bcrCXZgMMu%0A%2BeALTs5lkLE%3D|预订|240000G13710|G137|VNP|AOH|VNP|AOH|12:45|18:56|06:11|Y|hKEh2ZxlQDu3QYLC4k0DwAx0w37%2BQhxdKLH8M91BkTLFDHSk|20210807|3|P3|01|11|1|0|||||||||||有|有|16||O090M0|O9M|1|0||O0576000219215800016M100600021|0|||||1|#0#0|","rMs7tVoJWitGlW5v0vS3o0Yt2uo%2BlD30p7pvqz3tvA3u4Bde7mVGotB8WV%2BTaHdW4YfZtpsOTMMn%0AZCJZgZCtPJDt0jdAjBsqm2fwhUAfJgO94RFYByXbLiB9QLwpiuV7p9Cz4zlqcbIhEgk4HRSX6Up%2B%0AVegkh68833engRRnDHBDlQc9%2BbdKilgZuW04ln6QTRUvnb9pPtIQbVchAiGdZl4%2FNhih%2F8m5U8Zv%0A53xRwebMW0h35DqLmA2s7cgdL9jq1hn%2FjBbfUlJ26KLog7m4zEd7FgRsFv13cD6UTvP1rWoanBM3%0A|预订|2400000G1300|G13|VNP|SHH|VNP|SHH|13:00|17:35|04:35|Y|d6aUjdsIVa3coZLt0O%2FpfjhAKv70m40lTpcaVC05ov8UG%2F3d|20210807|3|P3|01|05|1|0|||||||||||有|有|16||O090M0|O9M|1|0||O0631000219233100016M104150021|0|||||1|5#1#0|","hER2y0v5d9KTh2b8gwcO4pDTzSQnjqJr3NitalNwt%2BSrWqonMtPfdvEpi1M6aO5c7oXGNzw9D2zJ%0AvdBZHfgOqVCzYQXIJ%2Fr%2FzpACWIAQH8tpBP%2FuMB3e7aekkswemLr1kV5uuOHEo%2F5I9oC1ZbdpYCds%0A%2F%2Fl0%2BHHuXU%2BrxMySwWdXsp7lgJTY%2F9vVmbJyXu%2BXtcCh90qKUO0wJdtb3Y0Plv8nRWFMOQX5XRpq%0A7M4bb1YYWKouYcRgrTcTv%2Fxvi2nUnY3IIqXWYCJLTlo3jI0W0hGl60KoJaxzAj2x3P2YVZvSplM%2B%0Ama4fa%2F%2BXvKY%3D|预订|240000G13919|G139|VNP|AOH|VNP|AOH|13:04|19:06|06:02|Y|E%2B61uK7VWnsU9GZGks3ismOMvvjBk0z1T7k0y6Z1xG8XH2NW|20210807|3|P4|01|11|1|0|||||||||||有|有|11||M0O090|MO9|1|0||M093000021O0553000219199800011|0|||||1|#0#0|","qpiJi7rgHTvvoIvOB5Z04UvImAch9Hee93zI0CfEJWVdHWZ7dttH5wADDc1ZNcpgIJEtpbBqQ93l%0AvnLhtpzFIdoME4WkdCdilmkueZ%2BjCa8Wp2JVFDv5iXHq0mxx0m8WeKof%2BaDwuFBZV4Q9tWjsJMRX%0AsiT2Qa3M%2BHA2KNSSLAkHAWZ%2BFY8KUlv%2FxMfEi8%2BuwIa6VBN1I56zccMJoc9qpm5t289kEiiXro%2BK%0A%2BjERia2UHgK7Blcv4T43%2FjSt6c%2FZLvlRqHE%2BtN0ygy8Us2KDmptyUzRC%2FJKk3sRUI4fPT6S8Iu5B%0AlXvgr6zDEQ0%3D|预订|2400000G1510|G15|VNP|AOH|VNP|AOH|14:00|18:33|04:33|Y|WXOzIAxjb0ZBigqco3mozk0jGa8G152mBYslZAWqjFnCapGO|20210807|3|P4|01|05|1|0|||||||||||有|有|16||M0O090|MO9|1|0||M103500021O0626000219231800016|0|||||1|0#1#Q03|","Iy3QtpOMR5Jwy95ahg6YRQDE3hVxjQCwxr9Kk%2FttdBQb5t74%2FQxQkW0zhtuxwFxtRYgxBidjBvQB%0A2cYKDy0yEdLeX2z8TQnx4kXdIlUwpCY9cv3SVv%2F7HNi5qK1SD%2B8cxWxkiB1SvIMh9bPxrfXPX5UB%0AdMwvTnTxAOvO6h2zTgcO9jadueywNJmMkkOvsD9ufBRqBC1TqfQwJeCSfa2gP8E9uJGEMPfbYmY%2B%0AadPjTG024Yh%2BaxygT7CcHZL52%2BpCCJsAY8R77jbzr7wDnhtUSPXp3zA7P%2BqP9EqswKLZQHMiMpLo%0AgwSuQqigkNs%3D|预订|240000G1470L|G147|VNP|AOH|VNP|AOH|14:27|20:43|06:16|Y|3PPNJvuqZtlY8VxBEBZQVFfIohoyD0Spa8VC2xLQunlbzzsZ|20210807|3|P3|01|11|1|0|||||||||||有|有|13||O0M090|OM9|1|0||O055300021M0930000219187300013|0|||||1|#1#0|","XAwSZcgUyBxvj6hl5%2FAkfzhjGnqnuoVy%2BWDeMcUbeylvHxi7wh5Hrgzvf6OoIQl5EviLTf4Rhtkw%0AIRcI7HIAtFULfmGm4gMiQf9VGeQuiMYPBuDQtgsYJFFe%2BLbKsGWk%2FbqMwYEHtRJiZ8VLIHvfSwD3%0AVxTerNP5r8wxwsQxn6W0pTn74%2FFJ9fyV%2BssfgcWdJvQbxZ7RdAQghVJg4eBgCTeJjp4%2FIkNo1Twi%0AkyysA%2Fsb52hqcKLzynAjNzij5NwFBtqqFgMFCWR7nUvueQ5PKB1zNlap7mS9Ypl6opa%2BRV%2FMHoOO%0A%2BsBM1ADgnx4%3D|预订|240000G1530N|G153|VNP|AOH|VNP|AOH|16:30|22:27|05:57|Y|rsQGWZUSwp7PzuJh76Q3hYth4SG1JCVvKgaC5Z1f%2FnmliJeD|20210807|3|P3|01|11|1|0|||||||||||有|19|5||O0M090|OM9|1|0||O055300021M0930000199174800005|0|||||1|#1#0|","G3X0jVUMO8BcHHihTI9MFqdtsuonAWUteGM1tjWJSfs7xm%2FTJbsFbzyx0dj%2FbXGArSyr%2B1wlOVIq%0AUYsMAFUhELaBHG2ZByKUJLpy3Gfb28dp6UL2Dp8cvG43B9kMbo3LRK9QdjkAFHX3qy4eftwCzmBk%0AePZGbD%2FWVPiZfV%2BCWZwW2r8QWj5M3jpH4A0l5rZ%2BSFeNMCnDC%2FW13qPYRDIttDPeVuMNw6JEYEf1%0ABLoIHiwyQeX9rUtXi%2B3XyiaHAH39FmXqMo2oZB4zs9aTZqzcShqiqomqCdhKI4KzBBO3xEWlMfw7%0AKR2DrI%2FZg3U%3D|预订|2400000G2110|G21|VNP|AOH|VNP|AOH|17:00|21:18|04:18|Y|xnO66d3bRWp5g3I5H3KcU61U5dgtKYKebBBvkyeDNbbPW8Km|20210807|3|P2|01|03|1|0|||||||||||有|有|12||M0O090|MO9|1|0||M103500021O0626000219231800012|0|||||1|0#1#Q03|O062600021","VFw6daHFhLUpT5C1e7zp3p2NTmO0hZaGEwjXe3LqK4g8ETzp91oCf3OlOWZZJKTntxyzw%2BrPtPpm%0AZdEtDEw0170atwpHs9n1KdJLFBlEhAfz2CoZ3Xjr3YTLm7kD4OLBxU35VP2JgQxgZXbbFXsO%2FNjk%0AQX%2B2GRlnTk5wmER7aspy72un1k9D1rjjs6J%2FYTgN%2F0bmT3JH%2BPNEqSG%2BIzJDaaGtZ46AzyB4%2FZIx%0A2Uhd9itiJ0bD%2BTZHGTpNjamnBH3EfmIA75RGOcqlXGTd4nI6uUazmFyB7mQCzJJ0GmXL1dUftTLQ%0AX3IRb07S%2Bgw%3D|预订|240000G1593F|G159|VNP|AOH|VNP|AOH|17:19|23:18|05:59|Y|zvxQESL8QkF0Gr0MYMIl3omagIfH6Gv2MldR2T8P90%2B9ExyN|20210807|3|P4|01|11|1|0|||||||||||有|有|有||M0O090|MO9|1|0||M088400021O0526000219174800021|0|||||1|#1#0|","mMVimpCwY%2FIwnchl%2BlLUTqTExMji31dPnKqKXjpe%2F3pHisAjyD%2FcBEGBJvuCd3x9JnhKfYGwt76z%0AsKhAISmkXHKC%2B%2FP8I3YiQMrYvYuqsnz6Es5h0VtpVFeyehethntxvoJM1SVVkZuh%2FsSabOKBUerT%0AGM%2FwTFYvG%2BMY5kt0glPxzheB2SaexrwsF99kQAfsQsch4yfudR%2F1C4l6NjHzAK4%2BHg7LgmbzXLAG%0AhrIb26MAw6h06H9ALc%2FAnzck7y6AzQBny1EEUuMzi15cY6DsQ1%2BVEvBg9k25HD0qRL4QznrURzJf%0Adlbak5pSyvg%3D|预订|240000G16110|G161|VNP|AOH|VNP|AOH|17:33|23:32|05:59|Y|BzomrRe5qJJgvRcWfoSwiFtKzMWrEsTXKMYwyNA%2BhYtZGxcX|20210807|3|P2|01|11|1|0|||||||||||有|有|17||M0O090|MO9|1|0||M088400021O0526000219174800017|0|||||1|#1#0|","NnJw7SHVUBh1xT2c6w1rIyDeSuW7DFCi36ATk%2BqcoqTWW%2Bbkp%2FwxZ8TMJrbW%2BHokEPcBWmsNr3rk%0AR4HqO1aLcGlx824kOJquEh1SEhuYHJ5AJmN5wZcjpj4cMOP2ADoFw9lSogSu9OmKqWDH1MPtm5DU%0A4FV3s4bE0%2F4meYR4dD8pP2DJEmwaeiUy4CHbb38094eIsxeyqs%2BLC7R6nRL9AEBis8UcAXO8jAui%0A8IMxgJXefwULFuq%2Bh%2BFXwNCs7M5Tq3Sw5n2eFFwJ8plck7OyuXugCj2lxhMjscuDI2%2BTh02hTUDM%0AWWg%2BQT2kQec%3D|预订|2400000G2502|G25|VNP|AOH|VNP|AOH|18:04|22:49|04:45|Y|UXUbqb43zuWyScM6YXRcUolhk97j6f79eGvnG1xWpBpW7NiU|20210807|3|P4|01|06|1|0|||||||||||有|有|8||M090O0|M9O|1|0||M1035000219231800008O062600021|0|||||1|5#1#0|","bR9jcfi9zF2%2B1hd%2FnjvMv93pQWZy6Wyf1y%2FtmBe0Wd8HAgVMBqp5O%2F5abqvSF%2Fl7ZvDEnhhtFvn1%0AQz4H5ZFs5ZG6Xzuki6oQVqjIWn1lL6IFqlU7cd%2Bmj47rEM5yBnRzHrUmKwNjCYN2KwmdoUznoVkx%0AKcu5FwNemeO8Jw%2FkD7QoH3%2Bz0LGAnxXb2t45xZAzUUCAr4Hcofpu11PlKA4o4%2FpgW0qOe0qIaQL7%0A%2BSMy90ghgZYyz9prSfijgwoJWAJa8Z0dtEgSK6HNQdA2y5Pnjb8twWAxb%2Bv0Dr%2FANujKJTek3AWF%0AGWBsrLmyNBDhPI6A|预订|240000D70904|D709|VNP|SHH|VNP|SHH|19:46|07:44|11:58|Y|e%2FRTAnIwYv2FfK1Fr6MwE1jYmu2wB0tDRu4rhr%2FnZE%2Btkm%2F5EDkxXfrd5XM%3D|20210807|3|P4|01|04|1|0||||有|||无||有||有||||J0I0O0W0|JIO2|1|0||J040400021I051200021O0269000212026903000|0|||||1|#1#0|","Epfqydn7qEp5fKAv3NjSndAMI53DLWzugyotiXZtBJ38PX45E2%2Bc1uMadz6PxgO5PMFxTlUmLu3s%0AZdlHBRLNek1JZrm6%2B1SoYoJvEcoeqzsucdIhdA%2FVLWVh398dr49IFB75uGgVzSEj4Mj2Lgbuh7Mb%0A5C9lmmtSlYGrKKWBn6ftXzVOyxrGUoK3UqoK%2F9uFgQo4H1Qv09VEk6rS%2FRH6lXvmE0ARjUy8%2BSsh%0ABjshn8uEJjRAf4U%2FEDgRrm03YLNCYhKhgOpnvbjye6LEzaHc8bdnAt2jBcht1EukJ6Ayv0bS49JH%0AHKKUKygNm8g%3D|预订|240000T10914|T109|BJP|SHH|BJP|SHH|20:05|11:00|14:55|Y|NURBJw5KzJPOrHV1i1EkhzSULnlRpo9PSegKwW%2FXTSx5VoQ%2BdqCcbanT24o%3D|20210807|3|P4|01|10|1|0||||有|||无||有|有|||||403010W0|4311|1|0||4047650021303045002110177500211017753000|0|||||1|#0#0|","hhSCrI3HSa4P38%2Bguf0nsfs2CCAid%2BJfVddlfAfVWfBnVPd1B4aDqucmS58NgHXmgFSFgcj33I%2FQ%0AXWFpHuKR0LF4aUKt%2BHcuhtaFDT6%2BIAuJycZTG3BCkhwN%2BvpvXaQZuo3tY0CNMRuPbGgMiWds%2FIJK%0AtWsMpBKFTcDCx%2BhbPal0Pfko9jVnAKjig1n8NOfEgwJZcrzu5DmoPe99GiqvOlk7I8hWGIvvz23M%0A3yrXHjFTAuXLRjMu1uLubjmkj30r2M00lFCyWXMkZllzVnHcGH6WxRCwhSs8L%2BiiSrdQAsRhkmwg%0A|预订|240000D70504|D705|BJP|SHH|BJP|SHH|21:21|09:21|12:00|Y|6fsOZCyA5QiGL6sHxchG05tTFELubVf4R02iILvjPEOBn9mx|20210807|3|P4|01|05|1|0||||有|||||有||有||||I0O0J0|IOJ|1|0||I047200021O024800021J037200021|0|||||1|#1#0|"],"flag":"1","map":{"SHH":"上海","VNP":"北京南","BJP":"北京","AOH":"上海虹桥"}},"messages":"","status":true}



首页上一页 1234 下一页尾页 34 条记录 3/4页
手机同步功能介绍
友情提示:以下图书配套资源能够实现手机同步功能
明日微信公众号
明日之星 明日之星编程特训营
客服热线(每日9:00-17:00)
400 675 1066
mingrisoft@mingrisoft.com
吉林省明日科技有限公司Copyright ©2007-2022,mingrisoft.com, All Rights Reserved长春市北湖科技开发区盛北大街3333号长春北湖科技园项目一期A10号楼四、五层
吉ICP备10002740号-2吉公网安备22010202000132经营性网站备案信息 营业执照