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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 228 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 772 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 930 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 984 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 966 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 161 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 267 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 194 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 700 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 151 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 190 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 133 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 62 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 91 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 158 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 167 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 243 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 285 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 215 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 266 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 201 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 224 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 211 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 294 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 590 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 514 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 445 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 247 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 250 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 107 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 103 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 143 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 573 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 482 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 137 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 84 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 444 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 188 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 107 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 123 KiB

View File

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