Парсер скринов lightshot )))

Discussion in 'Песочница' started by DarkFire666, 19 May 2021.

  1. DarkFire666

    DarkFire666 New Member

    Joined:
    4 May 2021
    Messages:
    4
    Likes Received:
    0
    Reputations:
    0
    Парсит скрины с lightshot, где nm = 970, номер с которого скрины начинают нумероваться, называл переменные как придумал, скрины сохраняются в ту директорию, где запускается скрипт. P.S Version 0.01 alfa
    ¯\_(ツ)_/¯
     

    Attached Files:

  2. DarkFire666

    DarkFire666 New Member

    Joined:
    4 May 2021
    Messages:
    4
    Likes Received:
    0
    Reputations:
    0
    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