Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import cfscrape
- from bs4 import BeautifulSoup
- import requests
- import os
- import string
- import random
- n = int(input("Enter images"))
- i = 0
- nm = 970
- while i < n:
- # URL = "https://prnt.sc/6gsikx" # For example
- # URL = "https://prnt.sc/" + rand_id
- def random_string(length=15, uppercase=True, lowercase=True, numbers=True):
- character_set = ''
- if uppercase:
- character_set += string.ascii_uppercase
- if lowercase:
- character_set += string.ascii_lowercase
- if numbers:
- character_set += string.digits
- return ''.join(random.choice(character_set) for i in range(length))
- rand_id = random_string(length=6, uppercase=False, lowercase=True)
- URL = "https://prnt.sc/" + rand_id
- def imagedrop(URL, folder):
- # try:
- # os.mkdir(os.path.join(os.getcwd(), folder))
- # except:
- # pass
- # os.chdir(os.path.join(os.getcwd(), folder))
- scrape = cfscrape.CloudflareScraper()
- site_http = scrape.get(URL)
- site_content = site_http.content
- soap = BeautifulSoup(site_content, 'html.parser')
- screen = soap.find_all('img', class_='no-click screenshot-image')
- for x in screen:
- scr_name = 'sad' + str(nm)
- scr_link = x['src']
- with open(scr_name.replace(' ', '-').replace('/', '') + '.jpg', 'wb') as fl:
- im = requests.get(scr_link)
- fl.write(im.content)
- print('Writing: ', scr_name)
- try:
- imagedrop(URL, 'test')
- except:
- pass
- nm = nm + 1
- i = i + 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement