调用“车来了”附近公交站点和每个站点所有线路接口,实现倒计时提醒功能


import requests
from fake_useragent import UserAgent
import re
import json

ua = UserAgent()
headers = {
    'User-Agent': ua.random,
}

# 拿到每个站点所有线路信息
def get_bus_comeapi():
    params = {
        # "modelVersion": "0.0.9",
        # "last_src": "app_huawei_store",
        "s": "android",
        # "stats_referer": "nearby",
        # "push_open": "1",
        # "stats_act": "auto_refresh",
        # "userId": "unknown",
        # "geo_lt": "5",
        # "lorder": "1",
        "geo_lat": "31.283958",
        # "vc": "110",
        # "sv": "7.0",
        "v": "3.53.4",
        "stationId": "021-2546",
        # "imei": "865551031290022",
        # "udid": "04c22de9-afc5-44eb-aecd-10b284587162",
        "cityId": "034",
        "sign": "rcDRbIfcB3s0xSisw1Jumg==",
        # "geo_type": "gcj",
        # "wifi_open": "1",
        # "mac": "02:00:00:00:00:00",
        # "deviceType": "JMM-AL00",
        # "lchsrc": "icon",
        # "nw": "WIFI",
        # "AndroidID": "dc21788d521004cc",
        # "geo_lac": "78.0",
        # "language": "1",
        # "first_src": "app_huawei_store",
        "geo_lng": "121.449813",
    }


    url = 'https://api.chelaile.net.cn/bus/stop!stationDetail.action'
    content = requests.get(url,headers = headers,params = params,verify=False).text
    result = re.findall(r'{.+}',content)[0]
    print(result)
    lines = json.loads(result)['jsonr']['data']['lines']

    print(content)
    print(lines)
    return lines
# get_bus_comeapi()

# 拿到周边所有公交站信息
def get_station():
    params = {
        # "last_src": "app_huawei_store",
        "s": "android",
        "sign": "6+IroqD6kOeEfX+gsenOvw==",
        # "push_open": "1",
        # "userId": "unknown",
        # "geo_type": "gcj",
        # "wifi_open": "1",
        # "mac": "02:00:00:00:00:00",
        # "deviceType": "JMM-AL00",
        # "geo_lt": "4",
        # "lchsrc": "icon",
        # "nw": "WIFI",
        # "geo_lat": "31.283962",
        # "AndroidID": "dc21788d521004cc",
        "lng": "121.44539927371892",
        # "vc": "110",
        # "sv": "7.0",
        # "geo_lac": "75.0",
        "v": "3.53.4",
        # "gpstype": "wgs",
        # "imei": "865551031290022",
        # "language": "1",
        # "udid": "04c22de9-afc5-44eb-aecd-10b284587162",
        # "first_src": "app_huawei_store",
        "lat": "31.289785790794657",
        "cityId": "034",
        # "geo_lng": "121.449813",
    }
    url = 'https://api.chelaile.net.cn/bus/stop!nearStations.action'
    content = requests.get(url,headers = headers,params = params,verify=False).text
    result = re.findall(r'{.+}',content)[0]
    print(result)
    lines = json.loads(result)['jsonr']['data']['nearStations']

    print(content)
    print(lines)
    return lines

# get_station()

你可能感兴趣的:(调用“车来了”附近公交站点和每个站点所有线路接口,实现倒计时提醒功能)