title: Using Aiohttp with Proxy
body: <p>I am trying to use async to get the HTML from a list of urls (identified by ids). I need to use a proxy.</p>
  
  <p>I am trying to use aiohttp with proxies like below:</p>
  
  <pre><code>import asyncio
  import aiohttp
  from bs4 import BeautifulSoup
  
  ids = ['1', '2', '3']
  
  async def fetch(session, id):
      print('Starting {}'.format(id))
      url = f'https://www.testing.com/{id}'
  
      async with session.get(url) as response:
          return BeautifulSoup(await response.content, 'html.parser')
  
  async def main(id):
      proxydict = {"http": 'xx.xx.x.xx:xxxx', "https": 'xx.xx.xxx.xx:xxxx'}
      async with aiohttp.ClientSession(proxy=proxydict) as session:
          soup = await fetch(session, id)
          if 'No record found' in soup.title.text:
              print(id, 'na')
  
  
  loop = asyncio.get_event_loop()
  future = [asyncio.ensure_future(main(id)) for id in ids]
  
  
  loop.run_until_complete(asyncio.wait(future))
  </code></pre>
  
  <p>According to an issue here: <a href="https://github.com/aio-libs/aiohttp/pull/2582" rel="noreferrer">https://github.com/aio-libs/aiohttp/pull/2582</a> it seems like <code>ClientSession(proxy=proxydict)</code> should work.</p>
  
  <p>However, I am getting an error <code>"__init__() got an unexpected keyword argument 'proxy'"</code></p>
  
  <p>Any idea what I should do to resolve this please?
  Thank you.</p>