All Projects → littlecodersh → Trip

littlecodersh / Trip

Licence: other
Async HTTP for Humans, coroutine Requests ⛺️

Programming Languages

python
139335 projects - #7 most used programming language

Labels

Projects that are alternatives of or similar to Trip

Qtnetworkng
QtNetwork Next Generation. A coroutine based network framework for Qt/C++, with more simpler API than boost::asio.
Stars: ✭ 125 (-40.76%)
Mutual labels:  coroutine
Aint Queue
🚀 An async-queue library built on top of swoole, flexable multi-consumer, coroutine supported. 基于 Swoole 的一个异步队列库,可弹性伸缩的工作进程池,工作进程协程支持。
Stars: ✭ 143 (-32.23%)
Mutual labels:  coroutine
Hyperf Skeleton
🛠 A skeleton of Hyperf framework that provided by official team
Stars: ✭ 162 (-23.22%)
Mutual labels:  coroutine
Mix
☄️ PHP CLI mode development framework, supports Swoole, WorkerMan, FPM, CLI-Server / PHP 命令行模式开发框架,支持 Swoole、WorkerMan、FPM、CLI-Server
Stars: ✭ 1,753 (+730.81%)
Mutual labels:  coroutine
Ext Zookeeper
🧑 Coroutine-based ZooKeeper Client for PHP
Stars: ✭ 140 (-33.65%)
Mutual labels:  coroutine
Unityfx.async
Asynchronous operations (promises) for Unity3d.
Stars: ✭ 143 (-32.23%)
Mutual labels:  coroutine
Yii2 Swoole
full solutions making yii2-framework run on swoole with coroutine.
Stars: ✭ 86 (-59.24%)
Mutual labels:  coroutine
Yurunhttp
YurunHttp 是开源的 PHP HTTP 客户端,支持链式操作,简单易用。完美支持Curl、Swoole 协程。QQ群:17916227
Stars: ✭ 197 (-6.64%)
Mutual labels:  coroutine
Fiber Ext
stackful-coroutines for PHP
Stars: ✭ 142 (-32.7%)
Mutual labels:  coroutine
Yii2 Swoole
make yii2 project runing on swoole
Stars: ✭ 161 (-23.7%)
Mutual labels:  coroutine
Archer
基于协程Swoole的Task组件,支持多种模式。轻松实现协程Task的队列、并发、Defer、计时器等 | Swoole coroutine task kit - Swoole Humanization Library
Stars: ✭ 132 (-37.44%)
Mutual labels:  coroutine
Unitask
Provides an efficient allocation free async/await integration for Unity.
Stars: ✭ 2,547 (+1107.11%)
Mutual labels:  coroutine
Co
Art of C++. Flag, logging, unit-test, json, go-style coroutine and more.
Stars: ✭ 2,264 (+972.99%)
Mutual labels:  coroutine
Awesomegithub
🔥Android Github客户端,基于组件化开发,支持账户密码与认证登陆。使用Kotlin语言进行开发,项目架构是基于JetPack&DataBinding的MVVM;项目中使用了Arouter、Retrofit、Coroutine、Glide、Dagger与Hilt等流行开源技术。
Stars: ✭ 128 (-39.34%)
Mutual labels:  coroutine
Minicoro
Single header asymmetric stackful cross-platform coroutine library in pure C.
Stars: ✭ 164 (-22.27%)
Mutual labels:  coroutine
Channel
一行代码发送和接收事件LiveData|LifeCycle|Coroutine特性的事件总线框架
Stars: ✭ 108 (-48.82%)
Mutual labels:  coroutine
Guzzle Swoole
让基于 Guzzle 的项目完美无缝兼容 Swoole 协程,支持:Guzzle、Elasticsearch client——来自宇润 PHP 全家桶
Stars: ✭ 143 (-32.23%)
Mutual labels:  coroutine
Libgo
Go-style concurrency in C++11
Stars: ✭ 2,521 (+1094.79%)
Mutual labels:  coroutine
Mvvmtemplate
An Android Template with MVVM and Clean Architecture
Stars: ✭ 182 (-13.74%)
Mutual labels:  coroutine
Srs
SRS is a simple, high efficiency and realtime video server, supports RTMP, WebRTC, HLS, HTTP-FLV, SRT and GB28181.
Stars: ✭ 16,734 (+7830.81%)
Mutual labels:  coroutine

Trip: Async HTTP for Humans

pypi

TRIP, Tornado & Requests In Pair, an async HTTP library for Python.

Simple as Requests, Trip let you get rid of annoying network blocking.

Coroutine in python 2.7+ can be this simple:

import trip

def main():
    r = yield trip.get('https://httpbin.org/get', auth=('user', 'pass'))
    print(r.content)

trip.run(main)

With Trip, you may finish one hundred requests in one piece of time.

Trip gets its name from two powerful site packages and aims to combine them together. Trip refers to 'Tornado & Requests In Pair', TRIP. To put them together, I reused much of their codes about structure and dealing. Actually I only made little effort to make a mixture. Thanks to Tornado and Requests.

Through using Trip, you may take full advantage of Requests, including: Sessions with Cookie persistence, browser-style SSL verification, automatic content decoding, basic/digest authentication, elegant key/value Cookies. Meanwhile, your requests are coroutine like using AsyncHTTPClient of Tornado, network blocking will not be a problem.

Found difficult optimizing spiders' time consuming? Found tricky using asyncio http packages? Found heavy custimizing big spider framework? Try Trip, you will not regret!

Installation

Paste it into your console and enjoy:

python -m pip install trip

Documents

Documents are here: http://trip.readthedocs.io/zh/latest/

Advanced usage

Some of the advaced features are listed here:

Using async and await in python 3

import trip

async def main():
    r = await trip.get('https://httpbin.org/get', auth=('user', 'pass'))
    print(r.content)

trip.run(main)

Sessions with Cookie persistence

import trip

def main():
    s = trip.Session()
    r = yield s.get(
        'https://httpbin.org/cookies/set',
        params={'name': 'value'},
        allow_redirects=False)
    r = yield s.get('https://httpbin.org/cookies')
    print(r.content)

trip.run(main)

Event hooks

import trip

def main():
    def print_url(r, *args, **kwargs):
        print(r.url)
    def record_hook(r, *args, **kwargs):
        r.hook_called = True
        return r
    url = 'http://httpbin.org/get'
    r = yield trip.get('http://httpbin.org', hooks={'response': [print_url, record_hook]})
    print(r.hook_called)

trip.run(main)

Timeouts

import trip

def main():
    r = yield trip.get('http://github.com', timeout=0.001)
    print(r)

trip.run(main)

Proxy

import trip

proxies = {
    'http': '127.0.0.1:8080',
    'https': '127.0.0.1:8081',
}

def main():
    r = yield trip.get('https://httpbin.org/get', proxies=proxies)
    print(r.content)

trip.run(main)

How to contribute

  1. You may open an issue to share your ideas with me.
  2. Or fork this project and do it your own on master branch.
  3. Please write demo codes of bugs or new features. You know, codes help.
  4. Finally if you finish your work and make a pull request, I will merge it in time after essential tests.

Similiar projects

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].