Oct 26, 2018 04:00 PM
(This post was last modified: Oct 26, 2018 04:03 PM by Bestandsextensie.)
hi there, i wanted to fill up my folder with some good HighResolution pictures nam sayin so i created this script the thing is on the site theres two links one thumbnail and one full resolution, it grabs both.
so i am asking for a way to not get duplicates and explain it please, feel free to use this script if u dont care about duplicates or use it yourself
becareful it grabs every url that has an image on it ending with .jpg
on the site i targeted the thumbnail = 123.jpg thats can pop up but the real link also redirects to 123.jpg so i get two values
to use it add an url from a 4chan thread in the imageGrabber function in main. i cant add urls yet so
so i am asking for a way to not get duplicates and explain it please, feel free to use this script if u dont care about duplicates or use it yourself
becareful it grabs every url that has an image on it ending with .jpg
on the site i targeted the thumbnail = 123.jpg thats can pop up but the real link also redirects to 123.jpg so i get two values
Code
import requests
from bs4 import BeautifulSoup
from random import randint
def imageGrabber(url):
req = requests.get(url)
soup = BeautifulSoup(req.content, 'html.parser')
images = soup.findAll('a', href=True)
for img in images:
img = img.get('href')
if img.endswith('.jpg'):
f = open(str(randint(0,999))+'.jpg','wb')
img = 'https:'+img
print(img)
f.write(requests.get(img).content)
f.close()
def main():
imageGrabber('')
if __name__ == '__main__':
main()to use it add an url from a 4chan thread in the imageGrabber function in main. i cant add urls yet so

