urlfetch


Nameurlfetch JSON
Version 2.0.1 PyPI version JSON
download
home_pagehttps://github.com/ifduyue/urlfetch
SummaryAn easy to use HTTP client
upload_time2023-08-03 16:36:10
maintainer
docs_urlhttps://pythonhosted.org/urlfetch/
authorYue Du
requires_python>=3.5
licenseBSD
keywords httpclient urlfetch
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            urlfetch |github-actions-badge| |furyio-badge|
==========================================================

.. |github-actions-badge| image:: https://github.com/ifduyue/urlfetch/actions/workflows/test.yml/badge.svg
    :target: https://github.com/ifduyue/urlfetch/actions/workflows/test.yml

.. |furyio-badge| image:: https://badge.fury.io/gh/ifduyue%2Furlfetch.svg
    :target: https://badge.fury.io/gh/ifduyue%2Furlfetch

urlfetch is a simple, lightweight and easy to use HTTP client for Python.
It is distributed as a single file module and has no depencencies other than the Python Standard Library.


Highlights
-------------

* Distributed as a single file module, has no depencencies other than the Python Standard Library.
* Pure Python, works fine with gevent_.
* Small codebase, about 1000 lines and 30% are comments and blank lines. Only 10 minutes you can know every detail.
* Random user-agent.
* Support streaming.

.. _gevent: http://www.gevent.org/

Installation
-------------
::

    $ pip install urlfetch


Hello, world
-------------

.. code-block:: python

    import urlfetch

    response = urlfetch.get('http://python.org/')
    print response.status, response.reason
    print len(response.content)

Uploading files
----------------

.. code-block:: python

    import urlfetch

    response = urlfetch.post(
        'http://127.0.0.1:8888/upload',
        headers = {
            'Referer': 'http://127.0.0.1/',
        },
        files = {
            'fieldname1': open('/path/to/file', 'rb'),
            #'fieldname2': 'file content', # file must have a filename
            'fieldname3': ('filename', open('/path/to/file2', 'rb')),
            'fieldname4': ('filename', 'file content'),
        },
        data = {
            'foo': 'bar'
        },
    )

    print response.status, response.content


Testing
--------

.. __: http://bottlepy.org/
.. __: http://gunicorn.org/

To run the tests, urlfetch relies on `bottle`__ and `gunicorn`__.
If the tests are run by calling ``python setup.py test``,  the
dependencies will be handled automatically (via ``tests_require``).
So, if you want to run the tests directly, that is,
``python tests/testall.py``, make sure bottle and gunicorn are installed
under the PYTHONPATH.
            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/ifduyue/urlfetch",
    "name": "urlfetch",
    "maintainer": "",
    "docs_url": "https://pythonhosted.org/urlfetch/",
    "requires_python": ">=3.5",
    "maintainer_email": "",
    "keywords": "httpclient urlfetch",
    "author": "Yue Du",
    "author_email": "ifduyue@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/bb/a1/e1d6b044af47c9ccda8b04b8b03c78faec238f7fadac3526f2ce86205033/urlfetch-2.0.1.tar.gz",
    "platform": null,
    "description": "urlfetch |github-actions-badge| |furyio-badge|\n==========================================================\n\n.. |github-actions-badge| image:: https://github.com/ifduyue/urlfetch/actions/workflows/test.yml/badge.svg\n    :target: https://github.com/ifduyue/urlfetch/actions/workflows/test.yml\n\n.. |furyio-badge| image:: https://badge.fury.io/gh/ifduyue%2Furlfetch.svg\n    :target: https://badge.fury.io/gh/ifduyue%2Furlfetch\n\nurlfetch is a simple, lightweight and easy to use HTTP client for Python.\nIt is distributed as a single file module and has no depencencies other than the Python Standard Library.\n\n\nHighlights\n-------------\n\n* Distributed as a single file module, has no depencencies other than the Python Standard Library.\n* Pure Python, works fine with gevent_.\n* Small codebase, about 1000 lines and 30% are comments and blank lines. Only 10 minutes you can know every detail.\n* Random user-agent.\n* Support streaming.\n\n.. _gevent: http://www.gevent.org/\n\nInstallation\n-------------\n::\n\n    $ pip install urlfetch\n\n\nHello, world\n-------------\n\n.. code-block:: python\n\n    import urlfetch\n\n    response = urlfetch.get('http://python.org/')\n    print response.status, response.reason\n    print len(response.content)\n\nUploading files\n----------------\n\n.. code-block:: python\n\n    import urlfetch\n\n    response = urlfetch.post(\n        'http://127.0.0.1:8888/upload',\n        headers = {\n            'Referer': 'http://127.0.0.1/',\n        },\n        files = {\n            'fieldname1': open('/path/to/file', 'rb'),\n            #'fieldname2': 'file content', # file must have a filename\n            'fieldname3': ('filename', open('/path/to/file2', 'rb')),\n            'fieldname4': ('filename', 'file content'),\n        },\n        data = {\n            'foo': 'bar'\n        },\n    )\n\n    print response.status, response.content\n\n\nTesting\n--------\n\n.. __: http://bottlepy.org/\n.. __: http://gunicorn.org/\n\nTo run the tests, urlfetch relies on `bottle`__ and `gunicorn`__.\nIf the tests are run by calling ``python setup.py test``,  the\ndependencies will be handled automatically (via ``tests_require``).\nSo, if you want to run the tests directly, that is,\n``python tests/testall.py``, make sure bottle and gunicorn are installed\nunder the PYTHONPATH.",
    "bugtrack_url": null,
    "license": "BSD",
    "summary": "An easy to use HTTP client",
    "version": "2.0.1",
    "project_urls": {
        "Homepage": "https://github.com/ifduyue/urlfetch"
    },
    "split_keywords": [
        "httpclient",
        "urlfetch"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "bba1e1d6b044af47c9ccda8b04b8b03c78faec238f7fadac3526f2ce86205033",
                "md5": "fa7c5b06245c6e2eca7eb215c58f49a9",
                "sha256": "bc1e60a71b2c6177b25830dda39daf2a230b6ce11c7bf2186098a785523adaa5"
            },
            "downloads": -1,
            "filename": "urlfetch-2.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "fa7c5b06245c6e2eca7eb215c58f49a9",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.5",
            "size": 67064,
            "upload_time": "2023-08-03T16:36:10",
            "upload_time_iso_8601": "2023-08-03T16:36:10.898157Z",
            "url": "https://files.pythonhosted.org/packages/bb/a1/e1d6b044af47c9ccda8b04b8b03c78faec238f7fadac3526f2ce86205033/urlfetch-2.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-08-03 16:36:10",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "ifduyue",
    "github_project": "urlfetch",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "urlfetch"
}
        
Elapsed time: 0.10528s