pengpan/91160

作者老哥好,好不容易刷出来号,但下单报错呢,KeyError: 'val'

seryte opened this issue · 2 comments

2021-01-21 15:00:02,457 - root - INFO - 刷到票了,开抢了...
2021-01-21 15:00:11,748 - root - INFO - https://www.91160.com/guahao/ystep1/uid-**/depid-4***/schid-600924279884b*****195b7f.html
Traceback (most recent call last):
  File "main.py", line 536, in <module>
    run()
  File "main.py", line 526, in run
    get_ticket(tickets[0], unit_id, dep_id)
  File "main.py", line 297, in get_ticket
    "detlid": soup.select('#delts li')[0].attrs["val"],
KeyError: 'val'

另外有点拙见,能否不登录的情况下先去查号,等查到有号再立马登录下单,会不会就不403了

HTML原文:

<ul class="fn-clear" id="delts">
	<li isRealTime="0"  val="600d18ab509717bf74d94e2a" class="">14:30-15:00</li>
</ul>

代码中获取600d18ab509717bf74d94e2a的方式为:

soup.select('#delts li')[0].attrs["val"]

正常情况下是不会报错的,这个要看原网页HTML具体是什么样的才能定位问题

若有更好的建议或想法欢迎 Pull requests