Création auto dossier
This commit is contained in:
@ -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)
|
||||
|
||||
Reference in New Issue
Block a user