diff --git a/cogs/general.py b/cogs/general.py index 31193e3..62d2ee0 100644 --- a/cogs/general.py +++ b/cogs/general.py @@ -19,7 +19,8 @@ class General(commands.Cog): return await ctx.reply('rss url not configured.') try: - async with aiohttp.ClientSession() as session: + headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'} + async with aiohttp.ClientSession(headers=headers) as session: async with session.get(rss_url) as resp: text = await resp.text() diff --git a/twitterbridge/rss.py b/twitterbridge/rss.py index a752f95..7747bfd 100644 --- a/twitterbridge/rss.py +++ b/twitterbridge/rss.py @@ -42,7 +42,12 @@ class TwitterRSSForwarder: f.write(self.last_guid or '') async def _poll(self): - feed = feedparser.parse(self.rss_url) + headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'} + async with aiohttp.ClientSession(headers=headers) as session: + async with session.get(self.rss_url) as resp: + text = await resp.text() + + feed = feedparser.parse(text) if feed.bozo and not feed.entries: print(f'twitter rss feed error: {feed.bozo_exception}')