zoukankan      html  css  js  c++  java
  • 【python】接口自动化初识第一站

    1.下载安装requests

     下载的时候可能会出现pip版本过旧的问题,直接复制返回结果中提示的代码,下载最新版的pip就行


    #import requests

    # response=requests.get('http://www.baidu.com/')
    # response=requests.get('http://www.hnxmxit.com/')
    # print(response.content.decode('utf-8'))


    # 带参数的get请求写法一:
    # response01=requests.get('https://admin.vior.vip?username=luog&password=luogu3456')
    # print(response01.content.decode('utf-8'))
    #带参数的get请求写法二:
    # get_param_dict={'grant_type':'client_credential',
    # 'appid':'wx55614004f367f8ca',
    # 'secret':'65515b46dd758dfdb09420bb7db2c67f'}
    # response02=requests.get(url='https://api.weixin.qq.com/cgi-bin/token',
    # params=get_param_dict)
    # print(response02.content.decode('utf-8'))

    #模拟请求头部【请求头自己抓包】
    # header_info={'User-Agent':'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36 QIHU 360SE/12.2.1632.0'}
    # get_param_dict={'wd':'newdream'}
    # response02=requests.get(url='https://www.baidu.com',
    # params=get_param_dict,
    # headers=header"tag":{"id":633}_info)
    # print(response02.content.decode('utf-8'))

    #标签删除处理【access_token就是来自于上一步的返回值】
    # get_param_dict={"access_token":"39_nhMNeZ_taFZ4NpcGtkO2zuUSL47AcgyF92iHk1ebuYo2qfJsdMbiBqdXa-zR9tk5EBSEbLMdeWSUNfypcL4ag0hVOwRl6Xt5TzGj6NCTN5KV3PQqDbhI6vu82frH1UYhSwc24KkVuEeGCmdWBAPbABAMLA"}
    # response02=requests.get(url='https://api.weixin.qq.com/cgi-bin/tags/get',
    # params=get_param_dict)
    # tag_info_data={"tag":{"id":708}}
    # response02=requests.post(url='https://api.weixin.qq.com/cgi-bin/tags/delete',
    # params=get_param_dict,
    # json=tag_info_data)
    # print(response02.content.decode('utf-8'))
  • 相关阅读:
    软工实践4
    软工实践3
    软工实践1
    《暗时间》读书笔记
    关系规范化(数据库)
    关于Git的初步使用
    软件体系结构模式
    第六周编程总结
    第五周编程总结
    第四周编程总结
  • 原文地址:https://www.cnblogs.com/luoguoxing/p/14035098.html
Copyright © 2011-2022 走看看