{"id":13936311,"url":"https://github.com/littlecodersh/trip","last_synced_at":"2025-04-06T01:06:52.430Z","repository":{"id":62585320,"uuid":"82129923","full_name":"littlecodersh/trip","owner":"littlecodersh","description":"Async HTTP for Humans, coroutine Requests :tent:","archived":false,"fork":false,"pushed_at":"2023-08-14T21:47:28.000Z","size":97,"stargazers_count":208,"open_issues_count":5,"forks_count":27,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-03-30T00:10:01.924Z","etag":null,"topics":["coroutine","forhumans","python","trip"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/littlecodersh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2017-02-16T02:28:21.000Z","updated_at":"2024-06-19T05:14:52.000Z","dependencies_parsed_at":"2022-11-03T22:06:36.226Z","dependency_job_id":"c6f24e0a-18a4-4302-b84f-2e54a6e04612","html_url":"https://github.com/littlecodersh/trip","commit_stats":{"total_commits":41,"total_committers":2,"mean_commits":20.5,"dds":"0.024390243902439046","last_synced_commit":"4b444700d5cdc39c0570e8fc8d9ef9267377dabe"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/littlecodersh%2Ftrip","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/littlecodersh%2Ftrip/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/littlecodersh%2Ftrip/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/littlecodersh%2Ftrip/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/littlecodersh","download_url":"https://codeload.github.com/littlecodersh/trip/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247419859,"owners_count":20936012,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["coroutine","forhumans","python","trip"],"created_at":"2024-08-07T23:02:33.605Z","updated_at":"2025-04-06T01:06:52.389Z","avatar_url":"https://github.com/littlecodersh.png","language":"Python","readme":"# Trip: Async HTTP for Humans\n\n[![pypi][pypi-image]][pypi]\n[![][pyversion-image]][pypi]\n[![][thanks-image]][thanks]\n[![][chinese-image]][chinese]\n\nTRIP, Tornado \u0026 Requests In Pair, an async HTTP library for Python.\n\nSimple as Requests, Trip let you get rid of annoying network blocking.\n\nCoroutine in python 2.7+ can be this simple:\n\n```python\nimport trip\n\ndef main():\n    r = yield trip.get('https://httpbin.org/get', auth=('user', 'pass'))\n    print(r.content)\n\ntrip.run(main)\n```\n\nWith Trip, you may finish [one hundred requests in one piece of time][demo].\n\nTrip gets its name from two powerful site packages and aims to combine them together.\nTrip refers to 'Tornado \u0026 Requests In Pair', TRIP.\nTo put them together, I reused much of their codes about structure and dealing.\nActually I only made little effort to make a mixture. Thanks to [Tornado][tornado] \nand [Requests][requests].\n\nThrough using Trip, you may take full advantage of Requests, including:\nSessions with Cookie persistence, browser-style SSL verification, automatic content decoding,\nbasic/digest authentication, elegant key/value Cookies.\nMeanwhile, your requests are coroutine like using AsyncHTTPClient of Tornado, network blocking will\nnot be a problem.\n\nFound difficult optimizing spiders' time consuming?\nFound tricky using asyncio http packages?\nFound heavy custimizing big spider framework?\nTry Trip, you will not regret!\n\n## Installation\n\nPaste it into your console and enjoy:\n\n```bash\npython -m pip install trip\n```\n\n## Documents\n\nDocuments are here: [http://trip.readthedocs.io/zh/latest/][document]\n\n## Advanced usage\n\nSome of the advaced features are listed here:\n\n**Using async and await in python 3**\n\n```python\nimport trip\n\nasync def main():\n    r = await trip.get('https://httpbin.org/get', auth=('user', 'pass'))\n    print(r.content)\n\ntrip.run(main)\n```\n\n**Sessions with Cookie persistence**\n\n```python\nimport trip\n\ndef main():\n    s = trip.Session()\n    r = yield s.get(\n        'https://httpbin.org/cookies/set',\n        params={'name': 'value'},\n        allow_redirects=False)\n    r = yield s.get('https://httpbin.org/cookies')\n    print(r.content)\n\ntrip.run(main)\n```\n\n**Event hooks**\n\n```python\nimport trip\n\ndef main():\n    def print_url(r, *args, **kwargs):\n        print(r.url)\n    def record_hook(r, *args, **kwargs):\n        r.hook_called = True\n        return r\n    url = 'http://httpbin.org/get'\n    r = yield trip.get('http://httpbin.org', hooks={'response': [print_url, record_hook]})\n    print(r.hook_called)\n\ntrip.run(main)\n```\n\n**Timeouts**\n\n```python\nimport trip\n\ndef main():\n    r = yield trip.get('http://github.com', timeout=0.001)\n    print(r)\n\ntrip.run(main)\n```\n\n**Proxy**\n\n```python\nimport trip\n\nproxies = {\n    'http': '127.0.0.1:8080',\n    'https': '127.0.0.1:8081',\n}\n\ndef main():\n    r = yield trip.get('https://httpbin.org/get', proxies=proxies)\n    print(r.content)\n\ntrip.run(main)\n```\n\n## How to contribute\n\n1. You may open an issue to share your ideas with me.\n2. Or fork this [project][homepage] and do it your own on **master** branch.\n3. Please write demo codes of bugs or new features. You know, codes help.\n4. Finally if you finish your work and make a pull request, I will merge it in time after essential tests.\n\n## Similiar projects\n\n* [curequests][curequests]: Curio + Requests, Async HTTP for Humans.\n* [grequests][grequests]: Gevent + Requests.\n* [requests-threads][requests-threads]: Twisted Deferred Thread backend for Requests.\n* [requests-futures][requests-futures]: Asynchronous Python HTTP Requests for Humans using Futures.\n\n[pyversion-image]: https://img.shields.io/pypi/pyversions/trip.svg\n[pypi]: https://pypi.python.org/pypi/trip\n[pypi-image]: https://img.shields.io/pypi/v/trip.svg\n[chinese]: https://github.com/littlecodersh/trip/blob/master/README_CN.md\n[chinese-image]: https://img.shields.io/badge/README-切换语言-yellow.svg\n[thanks]: https://saythanks.io/to/littlecodersh\n[thanks-image]: https://img.shields.io/badge/Say%20Thanks-!-1EAEDB.svg\n[demo]: https://gist.github.com/littlecodersh/6803d2c3382de9a7793a0189db72f538\n[tornado]: https://github.com/tornadoweb/tornado\n[requests]: https://github.com/requests/requests\n[document]: http://trip.readthedocs.io/\n[homepage]: http://github.com/littlecodersh/trip\n[curequests]: https://github.com/guyskk/curequests\n[grequests]: https://github.com/kennethreitz/grequests\n[requests-threads]: https://github.com/requests/requests-threads\n[requests-futures]: https://github.com/ross/requests-futures\n","funding_links":[],"categories":["Python"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flittlecodersh%2Ftrip","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flittlecodersh%2Ftrip","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flittlecodersh%2Ftrip/lists"}