Does Google Compute Engine support making aiohttp get requests?

Viewed 101

So I'm trying to make a discord bot that checks a website and sends a message if the price of an item falls below a certain price. I got it working on my local machine, so I decided to host it on Google Compute Engine so it can run 24/7, but I ran into some issues.

After much testing, I've determined it's because Google Compute Engine doesn't like making aiohttp GET requests. Below is the isolated part of my code that is causing issues on Google Compute Engine, but works fine on my local machine.

import asyncio
from bs4 import BeautifulSoup
import aiohttp

async def myDriver():
    await httpReq()


async def httpReq():
    async with aiohttp.ClientSession() as session:
        async with session.get("https://www.newegg.com/p/N82E16824569005?Item=N82E16824569005&cm_sp=Homepage_BS-_-P1_24-569-005-_-12062020") as page:
            pageContent = await page.text()
            content = BeautifulSoup(pageContent, 'lxml')
            price = content.find("li", {"class": "price-current"}).strong.text.replace(",", "")
            print(price)


asyncio.run(myDriver())

Error:

File "GCEtestAiohttp.py", line 19, in httpReq
    price = content.find("li", {"class": "price-current"}).strong.text.replace(",", "") AttributeError: 'NoneType' object has no attribute 'strong'

notes:

  • "Debian GNU/Linux 10 (buster)"
  • python 3.7.3
  • aiohttp 3.6.3
  • I've tried similar code with the normal requests library on Google Compute Engine, and everything works fine, so I really believe its an issue with using aiohttp requests.
0 Answers
Related