Skip to content
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

Asyncify all the things #26

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 16 additions & 1 deletion carpetbag/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

Author: @politeauthority
"""

import aiohttp
import asyncio
from datetime import datetime
import logging
import os
Expand Down Expand Up @@ -220,6 +221,20 @@ def use_random_public_proxy(self, continents=[], ssl_only=False, test_proxy=True

return True

async def get_gud_proxies(self):
for proxy in self.get_public_proxies(ssl_only=False):
conn = aiohttp.TCPConnector(verify_ssl=False)
try:
async with aiohttp.ClientSession(trust_env=True, connector=conn) as session:
if not proxy.get('ssl'):
async with session.get('http://google.com', proxy='http://'+proxy.get('ip'), ssl=False) as resp:
print(resp.status)
print(await resp.text())
self.proxy_bag.append(proxy)
except:
pass
return True

def use_skip_ssl_verify(self):
"""
Sets CarpetBag up to not force a valid certificate return from the server. This exists mostly because I was
Expand Down
8 changes: 8 additions & 0 deletions test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import asyncio
from carpetbag import CarpetBag as cp

loop = asyncio.get_event_loop()
test = cp()
test2 = loop.run_until_complete(test.get_gud_proxies())
print(test2)
loop.close()