V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
yibinhp
V2EX  ›  Python

Python 脚本实现模拟 客户请求 API,求框架推荐

  •  
  •   yibinhp · 2021-05-08 09:10:24 +08:00 · 1927 次点击
    这是一个创建于 1055 天前的主题,其中的信息可能已经有所发展或是发生改变。

    自己是搞 java 的,在做类似开放平台的,有一个需求,想模拟 7 、8 个客户接入我们的平台,每个客户每隔 N 秒(随机一个数)随机调用一个接口,有什么框架推荐的嘛,想以脚本的形式跑,由于对 python 只是刚刚了解语法的程度,求各位老哥推荐

    8 条回复    2021-05-08 18:07:37 +08:00
    huifer
        1
    huifer  
       2021-05-08 09:11:44 +08:00
    request
    hushao
        2
    hushao  
       2021-05-08 09:20:16 +08:00 via iPhone   ❤️ 1
    同步 requests
    异步 httpx
    这俩用法基本一致,不同在于一个同步一个异步
    yibinhp
        3
    yibinhp  
    OP
       2021-05-08 09:35:54 +08:00
    @huifer @hushao OK,我去看看
    raptor
        4
    raptor  
       2021-05-08 09:49:23 +08:00
    写个 shell 脚本用 httpie 跑不就好了
    evil0harry
        5
    evil0harry  
       2021-05-08 10:53:56 +08:00
    用 postman 导出个可执行脚本,然后写个 bash 来随机?
    jiezhi
        6
    jiezhi  
       2021-05-08 10:56:44 +08:00
    省事点的话,先用浏览器请求下,然后复制 curl 出来,在线找个工具直接转成 py 的 requests 请求就好了。

    当然类似 paw 工具的话也可以将请求转成各种语言请求格式的。
    chogath
        7
    chogath  
       2021-05-08 17:34:20 +08:00
    为啥不用压测工具呢...
    ch2
        8
    ch2  
       2021-05-08 18:07:37 +08:00
    grequests
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3942 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 10:22 · PVG 18:22 · LAX 03:22 · JFK 06:22
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.