I've been trying to turn one of my programs async, but the Session doesn't seem to post the data.
from aiohttp import ClientSession as Session
from bs4 import BeautifulSoup as BS
import asyncio
class Finder(Session):
async def login(self, loginurl, homeurl, username, password):
async def getlogintoken(loginurl):
async with self.get(loginurl) as loginpage:
return(BS(await loginpage.text(), 'html.parser').select('#login > input[type=hidden]:nth-child(3)')[0]['value'])
async def postlogindata(loginurl, username, password, logintoken):
await self.post(loginurl, data={'username': username, 'password': password, 'logintoken': logintoken})
async def gethome(homeurl):
async with self.get(homeurl) as homepage:
print(homepage.url)
logintoken = await getlogintoken(loginurl)
print(logintoken)
await postlogindata(loginurl, username, password, logintoken)
await gethome(homeurl)
This is what I have and it works perfectly fine with requests (without all the async stuff), but with aiohttp it doesn't seem to work. Any help would be greatly appreciated!