#!/bin/env python3 import requests import datetime import threading import csv import json import random from concurrent.futures import ThreadPoolExecutor pool = ThreadPoolExecutor(16) threadLocal = threading.local() reader = csv.reader(ope
import requests
import datetime
import threading
import csv
import json
import random
from concurrent.futures import ThreadPoolExecutor
pool = ThreadPoolExecutor(16)
threadLocal = threading.local()
reader = csv.reader(open('***.csv'))
category = ['wilson1', 'wilson2', 'wilson3']
def push(i):
initialized = getattr(threadLocal, 'initialized', None)
if initialized is None:
threadLocal.initialized = True
threadLocal.s = requests.Session()
threadLocal.s.post(
'http://***/***',
json={
'username': 'admin',
'password': '1'
})
category_id = category.index(i[3])
threadLocal.s.post(
'http://***/***',
json={
'category_id': category_id,
'name': i[1],
'author': i[4],
})
for i in reader:
pool.submit(push, i)