Skip to content

Instantly share code, notes, and snippets.

Created September 3, 2016 14:15
Show Gist options
  • Save anonymous/efcd3a5f871e7f78431d326d97f8e9dd to your computer and use it in GitHub Desktop.
Save anonymous/efcd3a5f871e7f78431d326d97f8e9dd to your computer and use it in GitHub Desktop.
import aiohttp
import asyncio
wp_strings = '/wp-admin/', '/wp-content/', '/wp-includes/'
async def is_wp(url):
async with aiohttp.get(url) as response:
text = await response.text()
return any(x in text for x in wp_strings)
async def worker(urls, out):
for url in urls:
try:
result = await is_wp(url)
except Exception as e:
result = 'error'
out.write('{}|{}\n'.format(url, result))
async def main(in_file, out_file, workers=100):
with open(in_file, 'r') as fin:
with open(out_file, 'a') as fout:
urls = filter(None, map(str.rstrip, fin))
tasks = [worker(urls, fout) for _ in range(workers)]
await asyncio.wait(tasks)
if __name__ == '__main__':
task = main('xal', 'wp_xal.txt')
loop = asyncio.get_event_loop()
loop.run_until_complete(task)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment