Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- import asyncio
- from aiohttp import ClientSession
- async def fetch(url):
- try:
- async with ClientSession() as session:
- async with session.get(url) as response:
- return await url + '|' + checkwp(response.read())
- except Exception:
- return 'error'
- async def bound_fetch(sem, url):
- # getter function with semaphore
- async with sem:
- await fetch(url)
- async def run(loop, l):
- tasks = []
- # create instance of Semaphore
- sem = asyncio.Semaphore(1000)
- for i in l:
- # pass Semaphore to every GET request
- task = asyncio.ensure_future(bound_fetch(sem, i))
- tasks.append(task)
- responses = asyncio.gather(*tasks)
- await responses
- wpfile = open('wp_xal.txt', 'a')
- for item in responses:
- f.write("%s\n" % item)
- wpfile.close()
- def checkwp(html):
- if '/wp-admin/' in html or '/wp-content/' in html or '/wp-includes/' in html:
- return True
- else:
- return False
- def main():
- l = []
- f = open('xal', 'r')
- l = f.read().splitlines()
- f.close()
- count = len(l)
- print('%d domains loaded...' % count)
- loop = asyncio.get_event_loop()
- future = asyncio.ensure_future(run(loop, l))
- loop.run_until_complete(future)
- if __name__ == '__main__':
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement