Advertisement
Guest User

neko

a guest
Jul 6th, 2022
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.65 KB | None | 0 0
  1. import cfscrape
  2. from bs4 import BeautifulSoup
  3. import requests
  4. import os
  5. import string
  6. import random
  7.  
  8. n = int(input("Enter images"))
  9. i = 0
  10. nm = 970
  11.  
  12. while i < n:
  13.     # URL = "https://prnt.sc/6gsikx"  # For example
  14.  
  15.     # URL = "https://prnt.sc/" + rand_id
  16.  
  17.     def random_string(length=15, uppercase=True, lowercase=True, numbers=True):
  18.         character_set = ''
  19.         if uppercase:
  20.             character_set += string.ascii_uppercase
  21.         if lowercase:
  22.             character_set += string.ascii_lowercase
  23.         if numbers:
  24.             character_set += string.digits
  25.         return ''.join(random.choice(character_set) for i in range(length))
  26.  
  27.  
  28.     rand_id = random_string(length=6, uppercase=False, lowercase=True)
  29.  
  30.     URL = "https://prnt.sc/" + rand_id
  31.  
  32.  
  33.     def imagedrop(URL, folder):
  34.         # try:
  35.         # os.mkdir(os.path.join(os.getcwd(), folder))
  36.         # except:
  37.         # pass
  38.         # os.chdir(os.path.join(os.getcwd(), folder))
  39.  
  40.         scrape = cfscrape.CloudflareScraper()
  41.  
  42.         site_http = scrape.get(URL)
  43.  
  44.         site_content = site_http.content
  45.  
  46.         soap = BeautifulSoup(site_content, 'html.parser')
  47.         screen = soap.find_all('img', class_='no-click screenshot-image')
  48.  
  49.         for x in screen:
  50.             scr_name = 'sad' + str(nm)
  51.             scr_link = x['src']
  52.             with open(scr_name.replace(' ', '-').replace('/', '') + '.jpg', 'wb') as fl:
  53.                 im = requests.get(scr_link)
  54.                 fl.write(im.content)
  55.                 print('Writing: ', scr_name)
  56.  
  57.  
  58.     try:
  59.         imagedrop(URL, 'test')
  60.     except:
  61.         pass
  62.  
  63.     nm = nm + 1
  64.     i = i + 1
  65.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement