• python 网页登录了之后拿着cookie直接用于脚本程序获取api接口数据


    #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    #python3.7 cookie urllib3,requests
    #
    #pip install requests
    #分析网站数据源接口规律
    #当前支持基于‘网页登录了之后拿着cookie直接用于脚本程序获取api接口数据
    #
    #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    
    
    import urllib3  
    import requests
    
    HEADERS = {"cookie": 'JSESSIONID=0501AEF56FBF967A1A13F3E42688B877; sid=5af6074c-0e62-47c7-9a10-1f90335a8c40'}
    #url = 'http://192.168.145.37:8090/vmBatchNoController/queryVmBatchNoList.do?order=asc&limit=20&offset=20&planKind=6&pdtcorpCode=-1&batchno=&creator=&_=1666941577426'
    url = "http://192.168.145.37:8090/vmBatchNoController/queryVmBatchNoList.do?order=asc&limit=20&offset=40&planKind=6&pdtcorpCode=-1&batchno=&creator=&_=1666944167967"
    #print()
    #req = urllib3.request(url, headers=HEADERS)
    #print(req)
    #text = urllib3.urlopen(req).read()  
    #print(text)
    
    
    #http = urllib3.PoolManager()  # 线程池生成请求
    #res = http.request('POST', url, fields={"Accept": "application/json, text/javascript, */*; q=0.01",
    ''''
    "Accept-Encoding": "gzip, deflate",
    "Accept-Language": "zh-CN,zh;q=0.9",
    "Authorization": "Bearer eyJhbGciOiJIUzUxMiJ9.eyJkZXBhY29kZSI6IjM0IiwiZm9yY2UiOjAsInNpZCI6IjVhZjYwNzRjLTBlNjItNDdjNy05YTEwLTFmOTAzMzVhOGM0MCJ9.LPlQcXW53MbUpPexTXT7G1Fvn_BYpD3TtYQKeTraLhGCSsMdKukpTEGAVTQXin0wNGp4hjQRjztnqmzDcdtzuA",
    "Connection": "keep-alive",
    "Content-Type": "application/json",
    "Cookie": "JSESSIONID=0501AEF56FBF967A1A13F3E42688B877; sid=5af6074c-0e62-47c7-9a10-1f90335a8c40",
    "Host": "192.168.145.37:8090",
    "Referer": "http://192.168.145.37:8090/vmBatchNoController/batchInfoPage.do",
    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36",
    "X-Requested-With": "XMLHttpRequest"})
    '''
    
    #print(res.data.decode())
    
    fils = {
    
        'JSESSIONID':'0501AEF56FBF967A1A13F3E42688B877-666',
        'sid':'adb05949-f607-4f5e-9ae8-f8da3f5974bf-xxx'
        }
    
    r = requests.get(url,cookies=fils)
    res = r.text
    #print(res)
    #print(type(res))
    da01 = res.split(":[")[2]
    #print(da01)
    #筛出limit 20 json数据
    da02 = da01.split("]")[0]
    #print(da02)
  • 相关阅读:
    iOS7's subview trimmed if out of parent view bounds
    iOS 7 — navigationController is setting the contentInset and ContentOffset of my UIScrollView
    友盟统计-页面访问路径
    iOS-Get the NSString height in iOS 7
    php
    How to Install Laravel PHP Framework on CentOS 7 / Ubuntu 15.04
    apache-.htaccess
    ios-member center
    lamp
    mysql
  • 原文地址:https://www.cnblogs.com/ruiy/p/16836690.html
Copyright © 2020-2023  润新知