Giter VIP home page Giter VIP logo

easyrequests's Introduction

EasyRequests

EasyRequests is a minimalistic HTTP-Request Library that wraps aiohttp and asyncio in a small package that allows for sequential, parallel or even single requests. EasyRequests also supports dispatching each request as daemon (in a seperate thread)

Installation

Download the .py file and place it in your project. As of writing this, there is currently no PyPi download available!

Usage

Example usage

from easyrequests import  (Methods, Queue)

def callback(resp):
	print(f"Response received for: {resp.url}")

queue = Queue()

# A bunch of GET Requests
queue.add("https://twitter.com/", callback)
queue.add("https://facebook.com/", callback)
queue.add("https://google.com/", callback)
queue.add("https://aol.com/", callback)
queue.add("https://gmail.com/", callback)

# You can also specify the Method, in this case "POST"
queue.add("https://discord.com",
		  method=Methods.POST,
	      timeout=60,
	      data={"Hello":  "World"})

# clear -> After finishing, clear the queue
# background -> run as daemon or not
queue.runparallel(clear=True, background=True)

# If we don't do this, an exception will be thrown if the interpreter reaches the end of the file!
# We only need to use this if the task is run as daemon
queue.waitforfinish()

We can also do sequential requests by using the function runsequential() instead of runparallel().

EasyRequests also supports making single requests, without using a queue.

from easyrequests import  (Methods, Queue)

def callback(resp):
	print(f"Response received for: {resp.url}")

Queue.single("https://google.com/",
			 callback,
			 method=Methods.GET,
			 timeout=10,
		     background=True)

Please note

I created this library for personal use! If you encounter any problems, feel free to open an issue, though if I don't see the need to develop this further, I will abandon the project! Use at your own risk!

easyrequests's People

Contributors

avisix avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.