All Projects → msabramo → Requests Unixsocket

msabramo / Requests Unixsocket

Licence: apache-2.0
Use requests to talk HTTP via a UNIX domain socket

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Requests Unixsocket

Kiss Headers
💡Python package for HTTP/1.1 style headers. Parse headers to objects. Most advanced available structure for http headers.
Stars: ✭ 91 (-40.52%)
Mutual labels:  requests
Decryptlogin
APIs for loginning some websites by using requests.
Stars: ✭ 1,861 (+1116.34%)
Mutual labels:  requests
Incapsula Cracker Py3
Python3 compatible way to bypass sites guarded with Incapsula
Stars: ✭ 132 (-13.73%)
Mutual labels:  requests
Languagepod101 Scraper
Python scraper for Language Pods such as Japanesepod101.com 👹 🗾 🍣 Compatible with Japanese, Chinese, French, German, Italian, Korean, Portuguese, Russian, Spanish and many more! ✨
Stars: ✭ 104 (-32.03%)
Mutual labels:  requests
Ni Pyt
Materiály k předmětu NI-PYT na FIT ČVUT
Stars: ✭ 112 (-26.8%)
Mutual labels:  requests
Rxios
A RxJS wrapper for axios
Stars: ✭ 119 (-22.22%)
Mutual labels:  requests
Pitchfork
🎶 Unofficial python API for pitchfork.com reviews.
Stars: ✭ 67 (-56.21%)
Mutual labels:  requests
Grequests
A Go "clone" of the great and famous Requests library
Stars: ✭ 1,843 (+1104.58%)
Mutual labels:  requests
Bilibili member crawler
B站用户爬虫 好耶~是爬虫
Stars: ✭ 115 (-24.84%)
Mutual labels:  requests
Autolink
AutoLink是一个开源Web IDE自动化测试集成解决方案
Stars: ✭ 129 (-15.69%)
Mutual labels:  requests
Requests
A simple, yet elegant, HTTP library.
Stars: ✭ 46,558 (+30330.07%)
Mutual labels:  requests
Http request randomizer
Proxying Python Requests
Stars: ✭ 110 (-28.1%)
Mutual labels:  requests
Gsoc Organisation Scraper
Scrape GSoC organisations using a single script.
Stars: ✭ 121 (-20.92%)
Mutual labels:  requests
Just
Swift HTTP for Humans
Stars: ✭ 1,335 (+772.55%)
Mutual labels:  requests
Zhihu Spider
一个获取知乎用户主页信息的多线程Python爬虫程序。
Stars: ✭ 137 (-10.46%)
Mutual labels:  requests
Weibo Album Crawler
新浪微博相册大图多线程爬虫。
Stars: ✭ 83 (-45.75%)
Mutual labels:  requests
Docs
《数据采集从入门到放弃》源码。内容简介:爬虫介绍、就业情况、爬虫工程师面试题 ;HTTP协议介绍; Requests使用 ;解析器Xpath介绍; MongoDB与MySQL; 多线程爬虫; Scrapy介绍 ;Scrapy-redis介绍; 使用docker部署; 使用nomad管理docker集群; 使用EFK查询docker日志
Stars: ✭ 118 (-22.88%)
Mutual labels:  requests
Request Migrations
HTTP Request Migrations for API Versioning like Stripe
Stars: ✭ 149 (-2.61%)
Mutual labels:  requests
Python Simple Rest Client
Simple REST client for python 3.6+
Stars: ✭ 143 (-6.54%)
Mutual labels:  requests
Requestium
Integration layer between Requests and Selenium for automation of web actions.
Stars: ✭ 1,618 (+957.52%)
Mutual labels:  requests

requests-unixsocket

.. image:: https://badge.fury.io/py/requests-unixsocket.svg :target: https://badge.fury.io/py/requests-unixsocket :alt: Latest Version on PyPI

.. image:: https://travis-ci.org/msabramo/requests-unixsocket.svg?branch=master :target: https://travis-ci.org/msabramo/requests-unixsocket

Use requests <http://docs.python-requests.org/>_ to talk HTTP via a UNIX domain socket

Usage

Explicit ++++++++

You can use it by instantiating a special Session object:

.. code-block:: python

import json

import requests_unixsocket

session = requests_unixsocket.Session()

r = session.get('http+unix://%2Fvar%2Frun%2Fdocker.sock/info')
registry_config = r.json()['RegistryConfig']
print(json.dumps(registry_config, indent=4))

Implicit (monkeypatching) +++++++++++++++++++++++++

Monkeypatching allows you to use the functionality in this module, while making minimal changes to your code. Note that in the above example we had to instantiate a special requests_unixsocket.Session object and call the get method on that object. Calling requests.get(url) (the easiest way to use requests and probably very common), would not work. But we can make it work by doing monkeypatching.

You can monkeypatch globally:

.. code-block:: python

import requests_unixsocket

requests_unixsocket.monkeypatch()

r = requests.get('http+unix://%2Fvar%2Frun%2Fdocker.sock/info')
assert r.status_code == 200

or you can do it temporarily using a context manager:

.. code-block:: python

import requests_unixsocket

with requests_unixsocket.monkeypatch():
    r = requests.get('http+unix://%2Fvar%2Frun%2Fdocker.sock/info')
    assert r.status_code == 200

Abstract namespace sockets ++++++++++++++++++++++++++

To connect to an abstract namespace socket <https://utcc.utoronto.ca/~cks/space/blog/python/AbstractUnixSocketsAndPeercred>_ (Linux only), prefix the name with a NULL byte (i.e.: \0) - e.g.:

.. code-block:: python

import requests_unixsocket

session = requests_unixsocket.Session()
res = session.get('http+unix://\0test_socket/get')
print(res.text)

For an example program that illustrates this, see examples/abstract_namespace.py in the git repo. Since abstract namespace sockets are specific to Linux, the program will only work on Linux.

See also

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].