-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscrapper.py
More file actions
25 lines (21 loc) · 722 Bytes
/
scrapper.py
File metadata and controls
25 lines (21 loc) · 722 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from bs4 import BeautifulSoup
import requests, shutil, random, string
def randomword(length):
return ''.join(random.choice(string.lowercase) for i in range(length))
def download_img(url):
ext = url.split(".")[-1]
filename = randomword(10)
response = requests.get(url, stream=True)
with open(filename + '.'+ ext, 'wb') as out_file:
shutil.copyfileobj(response.raw, out_file)
del response
print(filename + " " + url)
pass
#url = "http://boards.4chan.org/wg/thread/5933467/beautiful-girl-thread"
url = raw_input('Enter your input:')
r = requests.get(url)
data = r.text
soup = BeautifulSoup(data)
links = soup.find_all("a", class_="fileThumb")
for link in links:
download_img("http:" + link.get('href'))