Readline of a file and use it in loop - newbiehere

19 views
Skip to first unread message

zonduha...@gmail.com

unread,
Mar 12, 2020, 1:08:45 AM3/12/20
to aio-libs
Hello! i am not a big coder and i am breaking my head trying to make a simple task... i just want to use the following code


import asyncio
import aiohttp


async def main():
async with aiohttp.ClientSession() as session:
async with session.get('http://httpbin.org/get') as resp:
print(resp.status)


asyncio.run(main())

but i want to implement the following and i don't  know how to do it.. please help. My idea is the following:

with open("urls.txt", "r") as urlFiles:
lines = urlFiles.read().splitlines()

and the somehow replace the session.get('https://...') with session.get('linesOfUrls.txt')

the urls.txt is something like:

etc

Reply all
Reply to author
Forward
0 new messages