socket-like-requests

Use Socket Like Requests Module


Keywords
Requests, TCP, Request, Socket
License
MIT
Install
pip install socket-like-requests==0.0.12

Documentation

Socket-Like-Requests

Send Requests With Socket Like The Default Requests Module in Python

Download

pip install socket_like_requests

# this is how to import it
from socket_like_requests import REQ

POST Method With

Requests Module :

r = requests.post('example.com')

My Module :

r = REQ().post('example.com')

Headers

Requests Module

hed = {}
hed["header"] = "value"
hed["header"] = "value"
hed["header"] = "value"
  
data = {}
data["Key1"] = "Value1"
data["Key2"] = "Value2"
data["Key3"] = "Value3"

r = requests.post('example.com', headers = hed, data = data)

My Module

hed = {}
hed["header"] = "value"
hed["header"] = "value"
hed["header"] = "value"
  
data = {}
data["Key1"] = "Value1"
data["Key2"] = "Value2"
data["Key3"] = "Value3"

r = REQ().post('example.com', headers = hed, data = data)

Add Proxy

Add Proxy ip:port Format

Example :

r = REQ().post('example.com', proxy = 'ip:port', proxy_type = 'socks4')

and the proxy type : http, socks4, socks5

Add ssl

r = REQ().post('example.com', verify = True)

if you don't want to use ssl replace it with False

Add Timeout

Default Timeout is 5 , but you can change it like this :

r = REQ().post('example.com', timeout = 5)

Print Response

To Print Response :

r = REQ().post('example.com')
print(r.text)

Print Status Code

To Print Status Code :

r = REQ().post('example.com')
print(r.sc)

Full Usage

hed = {}
hed["header"] = "value"
hed["header"] = "value"
hed["header"] = "value"
  
data = {}
data["Key1"] = "Value1"
data["Key2"] = "Value2"
data["Key3"] = "Value3"

r = REQ().post('example.com', headers = hed, data = data, proxy = 'ip:port', proxy_type = 'socks4', verify = True, timeout = 5)
print(r.text, r.sc)