-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Convert reddit links to a valid video link #27
Conversation
It is not possible to use aiohttp instead of httpx for some reason. I have tested extensively with requests, aiohttp, and httpx. requests and httpx will always work, while aiohttp will always return too many requests.
i've tested this, it works |
Is it not possible this is a the result of aiohttp's user-agent? Did you test that? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything looks good. Just waiting for a response on whether aiohttp's UA is the cause of 429s before approval.
Yeah, I looked into this. No clue why 429s are resulting, but it keeps to be due to aiohttp capitalizing a header or some SSL difference. |
After looking into it a bit more, I found a similar issue with aiohttp and the Telsa API returning 403s: aio-libs/aiohttp#5643. Drawing from the discussion on that issue, it looks like Reddit is returning a 429 for SSL issues. This code to override the SSL ciphers resolves the aiohttp 429 issue for me (where setting the UA alone did not): import aiohttp, asyncio, ssl
async def test():
async with aiohttp.ClientSession() as session:
headers = {'user-agent': 'AlexBot:v1.0.0'}
url = 'https://www.reddit.com/r/funny/comments/5gn8ru.json'
FORCED_CIPHERS = (
'ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+HIGH:'
'DH+HIGH:ECDH+3DES:DH+3DES:RSA+AESGCM:RSA+AES:RSA+HIGH:RSA+3DES'
)
sslcontext = ssl.create_default_context()
sslcontext.set_ciphers(FORCED_CIPHERS)
resp = await session.get(url=url, headers=headers, ssl=sslcontext)
print(resp)
loop = asyncio.get_event_loop()
loop.run_until_complete(test()) |
No description provided.