https://github.com/suminb/hallucination
A Python library for proxy server list management
https://github.com/suminb/hallucination
Last synced: 9 months ago
JSON representation
A Python library for proxy server list management
- Host: GitHub
- URL: https://github.com/suminb/hallucination
- Owner: suminb
- Created: 2011-02-04T06:17:47.000Z (over 15 years ago)
- Default Branch: master
- Last Pushed: 2020-01-14T16:15:40.000Z (over 6 years ago)
- Last Synced: 2025-08-16T02:37:25.088Z (11 months ago)
- Language: Python
- Homepage:
- Size: 184 KB
- Stars: 6
- Watchers: 5
- Forks: 1
- Open Issues: 4
-
Metadata Files:
- Readme: README.rst
Awesome Lists containing this project
README
Travis CI
---------
.. image:: https://travis-ci.org/suminb/hallucination.svg?branch=master
:target: https://travis-ci.org/suminb/hallucination
Prerequisites
-------------
- `python-requests `_
- SQLAlchemy_
.. _SQLAlchemy: http://www.sqlalchemy.org/
Usage
-----
Python invocation
`````````````````
To create database tables:
.. code-block:: python
proxy_factory = ProxyFactory(config=dict(db_uri='sqlite:///test.db'))
proxy_factory.create_db()
To import a text file containing a proxy server list:
.. code-block:: python
proxy_factory = ProxyFactory(config=dict(db_uri='sqlite:///test.db'))
proxy_factory.import_proxies('proxylist.txt')
Hallucination supports multiple database backends, as long as supported by SQLAlchemy_.
.. code-block:: python
proxy_factory = ProxyFactory(config=dict(db_uri='postgres://user:password@host/database'))
To make a request:
.. code-block:: python
r = proxy_factory.make_request('http://github.com/suminb/hallucination')
print r.text
You may specify timeout in seconds:
.. code-block:: python
r = proxy_factory.make_request('http://github.com/suminb/hallucination', timeout=5)
print r.text
Shell frontend
``````````````
To create an SQLite database file:
.. code-block:: console
python frontend.py -d proxy.db -c
To import a text file containing a proxy server list:
.. code-block:: console
python frontend.py -d proxy.db -i proxylist.txt
To export the proxy server list to a text file:
.. code-block:: console
python frontend.py -d proxy.db -x proxylist.txt
An exported file may look like the following:
.. code-block:: text
http://84.42.3.3:3128
http://77.94.48.5:80
http://209.62.12.130:8118
http://159.255.160.23:8080
http://50.57.170.105:80