Skip to main content
edited body
Source Link
Kevin
  • 374
  • 1
  • 2
  • 15

I was wondering if there was any way to make this script a lot faster - like instantly create 1000 accounts for example or at least in a matter of a few seconds. I’ve tried doing some async stuff myself but this is as far as I could get, I am just a beginner with asynchronous programming so any help is appreciated.

import asyncio import aiohttp async def make_numbers(numbers, _numbers): for i in range(numbers, _numbers): yield i async def make_penguinmake_account(): url = "https://example.com/sign_up.php" async with aiohttp.ClientSession() as session: async for x in make_numbers(35691, 5000000): async with session.post(url, data ={ "terms": 1, "captcha": 1, "email": "user%[email protected]" % str(x), "full_name": "user%s" % str(x), "password": "123456", "username": "auser%s" % str(x) }) as response: data = await response.text() print("-> Creating account number %d" % x) print (data) loop = asyncio.get_event_loop() try: loop.run_until_complete(make_penguinmake_account()) finally: loop.close() 

I was wondering if there was any way to make this script a lot faster - like instantly create 1000 accounts for example or at least in a matter of a few seconds. I’ve tried doing some async stuff myself but this is as far as I could get, I am just a beginner with asynchronous programming so any help is appreciated.

import asyncio import aiohttp async def make_numbers(numbers, _numbers): for i in range(numbers, _numbers): yield i async def make_penguin(): url = "https://example.com/sign_up.php" async with aiohttp.ClientSession() as session: async for x in make_numbers(35691, 5000000): async with session.post(url, data ={ "terms": 1, "captcha": 1, "email": "user%[email protected]" % str(x), "full_name": "user%s" % str(x), "password": "123456", "username": "auser%s" % str(x) }) as response: data = await response.text() print("-> Creating account number %d" % x) print (data) loop = asyncio.get_event_loop() try: loop.run_until_complete(make_penguin()) finally: loop.close() 

I was wondering if there was any way to make this script a lot faster - like instantly create 1000 accounts for example or at least in a matter of a few seconds. I’ve tried doing some async stuff myself but this is as far as I could get, I am just a beginner with asynchronous programming so any help is appreciated.

import asyncio import aiohttp async def make_numbers(numbers, _numbers): for i in range(numbers, _numbers): yield i async def make_account(): url = "https://example.com/sign_up.php" async with aiohttp.ClientSession() as session: async for x in make_numbers(35691, 5000000): async with session.post(url, data ={ "terms": 1, "captcha": 1, "email": "user%[email protected]" % str(x), "full_name": "user%s" % str(x), "password": "123456", "username": "auser%s" % str(x) }) as response: data = await response.text() print("-> Creating account number %d" % x) print (data) loop = asyncio.get_event_loop() try: loop.run_until_complete(make_account()) finally: loop.close() 
edited tags
Link
U13-Forward
  • 71.8k
  • 15
  • 100
  • 125
Source Link
Kevin
  • 374
  • 1
  • 2
  • 15

python async post requests

I was wondering if there was any way to make this script a lot faster - like instantly create 1000 accounts for example or at least in a matter of a few seconds. I’ve tried doing some async stuff myself but this is as far as I could get, I am just a beginner with asynchronous programming so any help is appreciated.

import asyncio import aiohttp async def make_numbers(numbers, _numbers): for i in range(numbers, _numbers): yield i async def make_penguin(): url = "https://example.com/sign_up.php" async with aiohttp.ClientSession() as session: async for x in make_numbers(35691, 5000000): async with session.post(url, data ={ "terms": 1, "captcha": 1, "email": "user%[email protected]" % str(x), "full_name": "user%s" % str(x), "password": "123456", "username": "auser%s" % str(x) }) as response: data = await response.text() print("-> Creating account number %d" % x) print (data) loop = asyncio.get_event_loop() try: loop.run_until_complete(make_penguin()) finally: loop.close()