2018-10-27 18:58:52 +05:30
|
|
|
import random
|
|
|
|
|
import requests
|
2018-11-15 15:41:01 +05:30
|
|
|
import time
|
|
|
|
|
import warnings
|
|
|
|
|
|
2018-11-14 10:50:22 +05:30
|
|
|
import core.config
|
2018-11-22 01:48:49 +05:30
|
|
|
from core.config import globalVariables
|
|
|
|
|
from core.utils import jsonize
|
2018-10-27 18:58:52 +05:30
|
|
|
|
2018-11-16 21:13:45 +05:30
|
|
|
warnings.filterwarnings('ignore') # Disable SSL related warnings
|
|
|
|
|
|
2018-10-27 18:58:52 +05:30
|
|
|
|
2018-11-10 17:33:48 +05:30
|
|
|
def requester(url, data, headers, GET, delay, timeout):
|
2018-11-22 01:48:49 +05:30
|
|
|
if core.config.globalVariables['jsonData']:
|
|
|
|
|
data = jsonize(data)
|
2018-10-27 18:58:52 +05:30
|
|
|
time.sleep(delay)
|
|
|
|
|
user_agents = ['Mozilla/5.0 (X11; Linux i686; rv:60.0) Gecko/20100101 Firefox/60.0',
|
2018-11-16 21:13:45 +05:30
|
|
|
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36'
|
|
|
|
|
'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36 OPR/43.0.2442.991']
|
2018-10-28 10:00:32 +05:30
|
|
|
if 'User-Agent' not in headers:
|
|
|
|
|
headers['User-Agent'] = random.choice(user_agents)
|
|
|
|
|
elif headers['User-Agent'] == '$':
|
|
|
|
|
headers['User-Agent'] = random.choice(user_agents)
|
2018-10-27 18:58:52 +05:30
|
|
|
if GET:
|
2018-11-16 21:13:45 +05:30
|
|
|
response = requests.get(url, params=data, headers=headers,
|
|
|
|
|
timeout=timeout, verify=False, proxies=core.config.proxies)
|
2018-10-27 18:58:52 +05:30
|
|
|
else:
|
2018-11-16 21:13:45 +05:30
|
|
|
response = requests.post(url, data=data, headers=headers,
|
|
|
|
|
timeout=timeout, verify=False, proxies=core.config.proxies)
|
2018-10-28 10:00:32 +05:30
|
|
|
return response
|