tools.py 文件源码

python
阅读 38 收藏 0 点赞 0 评论 0

项目:12306 作者: WangYihang 项目源码 文件源码
def getStationNamesVersion():
    '''
    ?? station_names.js ??????????
    '''
    logging.captureWarnings(True)
    url = "https://kyfw.12306.cn/otn/"
    station_name_version = "" # ????? 0 , ????????????????
    response = requests.get(url, verify=False)
    content = response.text.encode("UTF-8")
    soup = bs4.BeautifulSoup(content, "html.parser")
    scripts = soup.findAll("script")
    srcs = [] # ?? HTML ???? script ??? src ??
    for i in scripts:
        try: # ???? try ????? script ????? src ????
            src = i['src']
            srcs.append(src)
        except:
            pass
    for i in srcs: # ??????????? , ??????????????? , ?????????????
        if "station_name" in i: # ???? station_names ??? src
            station_name_version = i.split("station_version=")[1] # ?????
            # print "??????????? :" , station_name_version # ????
    return station_name_version
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号