CoolFace
Apppublic

hashir672/Python-red-gen-space

sourceHugging Faceupdated 2y agoView on Hugging Face
0likes
extract_all_membership.py45 linesDownload Raw Back to root
1import requests2from bs4 import BeautifulSoup3from urllib.parse import urlparse4import os5import aiohttp6import asyncio7import time8start = time.perf_counter()9def get_urls():10    url = 'https://hashir672.serv00.net/'11    reqs = requests.get(url)12    soup = BeautifulSoup(reqs.text, 'html.parser')13    14    urls = []15    for link in soup.find_all('a'):16        file_link = link.get('href')17        urls.append(url+file_link)18        19        # r = requests.get(url+file_link, allow_redirects=True)20        # open("./extract_member/" + str(file_name), 'wb').write(r.content)21        # print(file_name)22    return urls23 24 25urls = get_urls()26 27 28async def download_image(url):29    # print(f"Downloading {url}")30    async with aiohttp.ClientSession() as session:31        async with session.get(url) as resp:32            with open("./extract_member/"+url.split("/")[-1], 'wb') as f:33                f.write(await resp.read())34    # print(f"Done downloading {url}")35 36async def main():37    await asyncio.gather(*[download_image(url) for url in urls])38 39asyncio.run(main())40 41print(f"Total time: {time.perf_counter() - start}")42 43 44 45