Création auto dossier
@ -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)
|
||||
|
Before Width: | Height: | Size: 228 KiB |
Before Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 772 KiB |
Before Width: | Height: | Size: 930 KiB |
Before Width: | Height: | Size: 984 KiB |
Before Width: | Height: | Size: 60 KiB |
Before Width: | Height: | Size: 966 KiB |
Before Width: | Height: | Size: 161 KiB |
Before Width: | Height: | Size: 267 KiB |
Before Width: | Height: | Size: 194 KiB |
Before Width: | Height: | Size: 700 KiB |
Before Width: | Height: | Size: 151 KiB |
Before Width: | Height: | Size: 190 KiB |
Before Width: | Height: | Size: 133 KiB |
Before Width: | Height: | Size: 62 KiB |
Before Width: | Height: | Size: 1.8 MiB |
Before Width: | Height: | Size: 37 KiB |
Before Width: | Height: | Size: 91 KiB |
Before Width: | Height: | Size: 158 KiB |
Before Width: | Height: | Size: 26 KiB |
Before Width: | Height: | Size: 41 KiB |
Before Width: | Height: | Size: 167 KiB |
Before Width: | Height: | Size: 243 KiB |
Before Width: | Height: | Size: 285 KiB |
Before Width: | Height: | Size: 215 KiB |
Before Width: | Height: | Size: 266 KiB |
Before Width: | Height: | Size: 201 KiB |
Before Width: | Height: | Size: 2.3 MiB |
Before Width: | Height: | Size: 224 KiB |
Before Width: | Height: | Size: 211 KiB |
Before Width: | Height: | Size: 294 KiB |
Before Width: | Height: | Size: 590 KiB |
Before Width: | Height: | Size: 514 KiB |
Before Width: | Height: | Size: 445 KiB |
Before Width: | Height: | Size: 247 KiB |
Before Width: | Height: | Size: 250 KiB |
Before Width: | Height: | Size: 1.0 MiB |
Before Width: | Height: | Size: 107 KiB |
Before Width: | Height: | Size: 9.2 KiB |
Before Width: | Height: | Size: 103 KiB |
Before Width: | Height: | Size: 143 KiB |
Before Width: | Height: | Size: 573 KiB |
Before Width: | Height: | Size: 482 KiB |
Before Width: | Height: | Size: 137 KiB |
Before Width: | Height: | Size: 34 KiB |
Before Width: | Height: | Size: 41 KiB |
Before Width: | Height: | Size: 2.0 MiB |
Before Width: | Height: | Size: 84 KiB |
Before Width: | Height: | Size: 444 KiB |
Before Width: | Height: | Size: 1.6 MiB |
Before Width: | Height: | Size: 188 KiB |
Before Width: | Height: | Size: 107 KiB |
Before Width: | Height: | Size: 123 KiB |
15
scrape.py
@ -6,10 +6,10 @@ from bs4 import BeautifulSoup
|
||||
#Connexion web
|
||||
import mechanicalsoup
|
||||
import wget
|
||||
|
||||
from os import mkdir
|
||||
'''
|
||||
############## image scrapper ################
|
||||
Give me a url, i'll download all of its pictures !
|
||||
############## 4chan thread scrapper ################
|
||||
Give me a page, 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)
|
||||
|