• 【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'))
  • 相关阅读:
    文件的权限
    正则表达式
    软硬链接的学习
    linux系统中的文件类型和扩展名
    把数组排成最小的数
    整数中1出现的次数(从1到n整数中1出现的次数)
    最小的K个数
    连续子数组的最大和
    数组中出现次数超过一半的数字
    字符串的排列
  • 原文地址:https://www.cnblogs.com/luoguoxing/p/14035098.html
Copyright © 2020-2023  润新知