Création auto dossier

This commit is contained in:
Justine
2021-02-07 21:34:55 +01:00
parent f4ca5d5835
commit 6d08071c6c
55 changed files with 18 additions and 8 deletions

View File

@ -6,7 +6,7 @@ from bs4 import BeautifulSoup
#Connexion web
import mechanicalsoup
import wget
from os import mkdir
'''
############## 4chan thread scrapper ################
Give me a thread, i'll download all of its pictures !
@ -23,7 +23,7 @@ def getArgs():
parser = argparse.ArgumentParser()
parser.add_argument("-u", "--url", help = "URL of the thread", action="store", type=str, required=True)
parser.add_argument("-f", "--folder", help = "Folder in which downloads will go", action="store", type=str, required=True)
parser.add_argument("-f", "--folder", help = "Folder in which downloads will go, ex: ./downloads", action="store", type=str, required=True)
#Creating the args object
args=parser.parse_args()
@ -73,10 +73,15 @@ def scraper(soup):
def item_dl(sources, dlfolder):
'''
Download all items in the sources list to folder dlfolder"
Download all items in the sources list to folder dlfolder, which we try to create"
Args:
- sources : a list of URLs
'''
try:
mkdir(dlfolder)
except FileExistsError:
print(f"{dlfolder} already exists, not creating")
for source in sources:
fullsource = "http://" + source
name = wget.download(fullsource, out=dlfolder)