Take stock of those interesting open APIs

In the daily development and testing process, the support of test data is definitely indispensable.

There are many tools for simulating test data, for example: Mockaroo, DataGenerator, and the Faker introduced before can help us quickly generate random data, such as: name, address, email, mobile phone number, date, time, number, Boolean value wait.

However, these tools can only help us generate some basic data, and sometimes we need more than these basic data, for example: randomly generate a famous quote, randomly generate an ancient poem, get what happened today in history, get today's news etc. How can we achieve these requirements? It is obviously not realistic to write by yourself, and it will greatly reduce work efficiency. Therefore, we can obtain these data by calling some open interfaces.

In this article, I will share several interesting and free open interfaces, which can be used out of the box.

interface

random ancient poem

Request URL:https://api.apiopen.top/api/sentences

Request Method:GET

Function: Randomly generate an ancient poem, including the title and author.

def demo1(self):
    """
    古诗文
    @return: 例如:情人怨遥夜,竟夕起相思。——张九龄《望月怀远》
    """
    res = self.requests_http({
        'method': 'get',
        'url': 'https://api.apiopen.top/api/sentences'
    }).json()
    sentences = res['result']['name'] + '——' + res['result']['from']
    return sentences

random picture

Request URL:https://api.apiopen.top/api/getImages

Request Method:GET

Function: Randomly generate image links, and the type can be specified.

def demo2(self):
    """
    获取图片
    @return:
    """
    res = self.requests_http({
        'method': 'get',
        'url': 'https://api.apiopen.top/api/getImages',
        'params': {
            'page': 1,
            'size': 1,
            # type可选参数
            # animal/beauty/car/comic/food/game/movie/person/phone/scenery
            # 动物/美女/汽车/漫画/食物/游戏/电影/人物/手机/风景
            'type': ''
        }}).json()
    return res

random word

Request URL:https://api.oick.cn/yiyan/api.php

Request Method:GET

Function: Randomly output a sentence.

def demo3(self):
    """
    一言
    随机输出一句话(鸡汤)
    @return: 正因为有天空,所以云才能自由的地漂浮。
    """
    res = self.requests_http({
        'method': 'get',
        'url': 'https://api.oick.cn/yiyan/api.php'
    }).json()
    return res

social quotes

Request URL:https://api.oick.cn/yulu/api.php

Request Method:GET

Function: Randomly generate a social classic quotation.

def demo4(self):
    """
    社会经典语录
    @return: 花花世界迷人眼,没有能力别赛脸!
    """
    res = self.requests_http({
        'method': 'get',
        'url': 'https://api.oick.cn/yulu/api.php'
    }).json()
    return res

dog licking diary

Request URL:https://api.oick.cn/dog/api.php

Request Method:GET

Function: Randomly generate dog licking diaries.

def demo5(self):
    """
    舔狗日记
    @return: 今天一大早就去帮她海底捞排队,她男朋友想吃海底捞,我要是去晚了的话排不上队,她男朋友吃不上海底捞的话又该骂她,我怕她扛不住,她男朋友骂人很凶的.
    """
    res = self.requests_http({
        'method': 'get',
        'url': 'https://api.oick.cn/dog/api.php'
    }).json()
    return res

Toxic Chicken Soup

Request URL:https://api.oick.cn/dutang/api.php

Request Method:GET

Function: Randomly generate a sentence of poisonous chicken soup.

def demo6(self):
    """
    毒鸡汤
    @return: 世界上本没有路,走的人多了,老师就开始点名了。
    """
    res = self.requests_http({
        'method': 'get',
        'url': 'https://api.oick.cn/dutang/api.php'
    }).json()
    return res

history today

Request URL:https://api.oick.cn/lishi/api.php

Request Method:GET

Function: Get what happened today in history.

def demo7(self):
    """
    历史上的今天
    @return:
    """
    res = self.requests_http({
        'method': 'get',
        'url': 'https://api.oick.cn/lishi/api.php'
    }).json()
    for i in res['result']:
        print(i['date'] + ' ' + i['title'])

inspirational fishing

Request URL:http://bjb.yunwj.top/php/mo-yu/php.php

Request Method:GET

Function: Output the lying flat language of touching fish.

def demo8(self):
    """
    励志摸鱼
    @return:
    """
    res = self.requests_http({
        'method': 'get',
        'url': 'http://bjb.yunwj.top/php/mo-yu/php.php'
    }).json()
    return res

platform

Zero Seven Life API

URL: https://api.oick.cn

Core API

URL: http://bjb.yunwj.top/php/api/html.html?7

aggregated data

URL: https://www.juhe.cn/apiservice

Above, finish.

Keep your feet on the ground, look up at the stars, learn software testing with me, get promoted and raise your salary!

Finally:  The complete software testing video learning tutorial below has been sorted out and uploaded, and friends can get it for free if they need it【保证100%免费】

insert image description here

 These materials should be the most comprehensive and complete preparation warehouse for [software testing] friends. This warehouse has also accompanied tens of thousands of test engineers through the most difficult journey. I hope it can help you too!

Guess you like

Origin blog.csdn.net/wx17343624830/article/details/130485933