- Prntscr scrapper github windows
- Prntscr scrapper github windows
- Users who have contributed to this file
- Prntscr scrapper github windows
- Users who have contributed to this file
- SyntaxError: Missing parentheses in call to ‘print’. #2
- Comments
- Arkston commented Dec 27, 2018
- Danka32 commented Dec 28, 2018 •
- Ekali78 commented Dec 28, 2018
- wolfdizz commented Dec 28, 2018
- nazarpechka commented Jan 5, 2019
- nazarpechka commented Jan 5, 2019
- nazarpechka commented Jan 5, 2019
- markbookk commented Jan 10, 2019
- Saqo1995s commented Jan 13, 2019
- Saqo1995s commented Jan 13, 2019
- LightShot и чужие скриншоты
Prntscr scrapper github windows
Scraper for prnt.sc
The website LightShot or prnt.sc is a public image sharing website which is most well known for its quick and easy downloadable sharing utility activated by pressing the PrtScn key. It’s a very useful tool, however I noticed that it stores images based on a sequential 6 digit code, meaning the 1.3 billion or so images uploaded there can be indexed programmatically quite easily. That is what this utility does.
I have already published a set of around 13,000 images downloaded from the site on Kaggle which may be of use if you do not want to use the scraper utility.
This script was tested on the following python modules, however earlier/later versions may work fine:
Using the Script
The script takes 3 arguments as follows:
- —start_code : 6 character string made up of lowercase letters and numbers which is where the scraper will start.
- e.g. lj9me9
- —count : The number of images to scrape.
- e.g. 200
- —output_path : The path where images will be stored.
- e.g. output/
It can be very interesting to see what people upload to these sites, generally having sequential IDs of any type is bad, and the same applies here. People might not be aware that what they are uploading is visible to others, however prnt.sc/lightshot have not shown any inclination in wanting to change their site design.
As a result, this provides a useful way to create datasets of real world images. A useful/interesting use case is building a machine learning algorithm to classify images into categories, which requires some manual classification, but is nonetheless interesting and a good learning task.
Prntscr scrapper github windows
1 contributor
Users who have contributed to this file
import string , random , urllib , os , thread , array , sys |
if len ( sys . argv ) 2 : |
sys . exit ( » \033 [37mUsage: python » + sys . argv [ 0 ] + » (Number of threads)» ) |
threadAmount = int ( sys . argv [ 1 ]) |
print ( «=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+= \n This script is for educational purposes only! Use on your own responsibility! \n =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=» ) |
raw_input ( «Press ENTER if you have read and accept that you are fully responsible for using this script! \n » ) |
temp = 0 |
#while temp |
noneWorking = [ 0 , 503 , 4939 , 4940 , 4941 , 12003 , 5556 , 5082 ] |
def scrapePictures (): |
while True : |
# N = int(».join(random.choice(‘1’ + ‘2’) for _ in range(1))) |
amount = int ( » . join ( random . choice ( ‘5’ + ‘6’ ) for _ in range ( 1 ))) |
if amount == 6 : |
# N = int(».join(random.choice(‘3’) for _ in range(1))) |
N = 3 |
#name = str(len([name for name in os.listdir(‘.’) if os.path.isfile(name)]) — 1) |
###Generate the random url### |
picture = str ( » . join ( random . choice ( string . ascii_uppercase + string . digits + string . lowercase ) for _ in range ( N ))) |
picture2 = str ( » . join ( random . choice ( string . digits + string . lowercase ) for _ in range ( N ))) |
# printsc = «http://img.prntscr.com/img?url=http://i.imgur.com/» + «» + str(picture) + str(picture2) + «.jpg» |
# Trying to improve. |
name = picture + picture2 |
printsc = «http://i.imgur.com/» + «» + str ( picture ) + str ( picture2 ) + «.jpg» |
urllib . urlretrieve ( «» + printsc , str ( name ) + «.jpg» ) |
file = os . path . getsize ( str ( name ) + «.jpg» ) |
# print printsc |
# original print file. Currently in maintance mode. |
# print str(file) + » file» #Used to DEBUG and find the none working pictures |
if file in noneWorking : |
print «[-] Invalid: » + picture + picture2 |
os . remove ( name + «.jpg» ) |
else : |
print «[+] Valid: » + printsc |
#temp += 1 |
if amount == 5 : |
N = 5 |
# N = int(».join(random.choice(‘3’) for _ in range(1))) |
# N2 = int(».join(random.choice(‘2’) for _ in range(1))) |
#name = str(len([name for name in os.listdir(‘.’) if os.path.isfile(name)]) — 1) |
picture = str ( » . join ( random . choice ( string . ascii_uppercase + string . digits + string . lowercase ) for _ in range ( N ))) |
# picture2 = str(».join(random.choice(string.digits + string.lowercase) for _ in range(N2))) |
# printsc = «http://img.prntscr.com/img?url=http://i.imgur.com/» + «» + str(picture) + «.jpg» |
# Trying to improve. |
printsc = «http://i.imgur.com/» + «» + str ( picture ) + «.jpg» |
# printsc = «http://img.prntscr.com/img?url=http://i.imgur.com/» + «» + str(picture) + str(picture2) + «.jpg» #Porsiacaso necesito dividr 3 mixed y luego 2 numeros y minusculas |
name = picture |
urllib . urlretrieve ( «» + printsc , str ( name ) + «.jpg» ) |
file = os . path . getsize ( str ( name ) + «.jpg» ) |
#print printsc |
# print str(file) + » file» #Used to DEBUG and find the none working pictures |
if file in noneWorking : |
print «[-] Invalid: » + picture |
os . remove ( name + «.jpg» ) |
else : |
print «[+] Valid: » + printsc |
#temp += 1 |
tempVar2 = 1 |
#threadAmount = sys.argv[2] |
while ( tempVar2 threadAmount ): |
try : |
print ( «Starting thread #» + str ( tempVar2 )) |
thread . start_new_thread ( scrapePictures , ()) |
tempVar2 += 1 |
except : |
print «Error initializing thread. « |
#Make threads never stop |
while ( True ): |
temp = 1 + 1 |
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Prntscr scrapper github windows
1 contributor
Users who have contributed to this file
#Credits to ‘nazarpechka’ for helping out with this code |
import string , random , os , sys , _thread , httplib2 , time |
# from PIL import Image |
if len ( sys . argv ) 2 : |
sys . exit ( » \033 [37mUsage: python3 » + sys . argv [ 0 ] + » (Number of threads)» ) |
THREAD_AMOUNT = int ( sys . argv [ 1 ]) |
print ( «=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+= \n This script is for educational purposes only! Use on your own responsibility! \n =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=» ) |
input ( «Press ENTER if you have read and accept that you are fully responsible for using this script! \n » ) |
INVALID = [ 0 , 503 , 5082 , 4939 , 4940 , 4941 , 12003 , 5556 ] |
def scrape_pictures ( thread ): |
while True : |
#url = ‘http://img.prntscr.com/img?url=http://i.imgur.com/’ |
url = ‘http://i.imgur.com/’ |
length = random . choice (( 5 , 6 )) |
if length == 5 : |
url += » . join ( random . choice ( string . ascii_letters + string . digits ) for _ in range ( 5 )) |
else : |
url += » . join ( random . choice ( string . ascii_letters + string . digits ) for _ in range ( 3 )) |
url += » . join ( random . choice ( string . ascii_lowercase + string . digits ) for _ in range ( 3 )) |
url += ‘.jpg’ |
# print (url) |
filename = url . rsplit ( ‘/’ , 1 )[ — 1 ] |
# print (filename) |
h = httplib2 . Http ( ‘.cache’ + thread ) |
response , content = h . request ( url ) |
out = open ( filename , ‘wb’ ) |
out . write ( content ) |
out . close () |
file_size = os . path . getsize ( filename ) |
if file_size in INVALID : |
print ( «[-] Invalid: » + url ) |
os . remove ( filename ) |
else : |
print ( «[+] Valid: » + url ) |
for thread in range ( 1 , THREAD_AMOUNT + 1 ): |
thread = str ( thread ) |
try : |
_thread . start_new_thread ( scrape_pictures , ( thread ,)) |
except : |
print ( ‘Error starting thread ‘ + thread ) |
print ( ‘Succesfully started ‘ + thread + ‘ threads.’ ) |
while True : |
time . sleep ( 1 ) |
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
SyntaxError: Missing parentheses in call to ‘print’. #2
Comments
Arkston commented Dec 27, 2018
Every time I am trying to run the program it comes up with that File «code.py», line 34
print «[-] Invalid: » + picture + picture2
^
SyntaxError: Missing parentheses in call to ‘print’. Did you mean print(«[-] Invalid: » + picture + picture2)?
The text was updated successfully, but these errors were encountered:
Danka32 commented Dec 28, 2018 •
Possibly you have python 3 on your OS, https://github.com/Danka32/Adopted-prntscrScrapper , i adopted scrapper for new python.
Ekali78 commented Dec 28, 2018
Possibly you have python 3 on your OS, https://github.com/Danka32/Adopted-prntscrScrapper , i adopted scrapper for new python.
скажи как запустить твой скрипт
wolfdizz commented Dec 28, 2018
print «[-] Invalid: » + picture + picture2
^
SyntaxError: Missing parentheses in call to ‘print’. Did you mean print(«[-] Invalid: » + picture + picture2)?
nazarpechka commented Jan 5, 2019
код скрапера написан абсолютно бездарно, пришлось отрефакторить все ибо вообще не понимаю как это может работать. форкну и залью что вышло. кстати есть ли смысл юзать img.prntscr.com или i.imgur.com норм?
nazarpechka commented Jan 5, 2019
@Danka32 вопросы не к тебе, а к создателю оригинального кода (поскольку ты ничего толком и не изменил 🙂 ). за наводку спасибо
nazarpechka commented Jan 5, 2019
закинул свой вариант. он конечно немного другого предназначения но после исправления пары строк будет делать то же самое
markbookk commented Jan 10, 2019
I have updated the repository with the Python 3 version.
Saqo1995s commented Jan 13, 2019
I have updated the repository with the Python 3 version.
you need to reupdate for 3.7) raw_input( ) to input( ) and remove the «thread: from the inputs (and debug, I just looked visually)
Saqo1995s commented Jan 13, 2019
Если у тебя проблема с коммандой print то просто засунь весь код после print в скобки (). Как запустить, берешь полный путь к файлу включая диск и юзера пример: C:\Users\ТвойПрофиль\Desktop\ПапкаСоСкраппером Потом нажимаешь Win+R и пишешь cmd после пишешь комманду cd и путь к файлу, запускаешь и потом пишешь как на гит хабе python scrapper кол во фоток пятница, 28 декабря 2018г., 14:00 +01:00 от Ekali78 notifications@github.com :
…
Possibly you have python 3 on your OS, https://github.com/Danka32/Adopted-prntscrScrapper , i adopted scrapper for new python. скажи как запустить твой скрипт — You are receiving this because you commented. Reply to this email directly, view it on GitHub , or mute the thread .
при зажатой клавише «SHIFT» нажми на правый клик, в контекстном меню увидишь «открыть окно команд). А дальше знаешь
LightShot и чужие скриншоты
Сегодня я наткнулся на одну «уязвимость» сервиса для моментальных скриншотов LightShot.
Всё началось с того, что я загрузил очередной скриншот и вспомнил недавнюю статью на хабре, где сливались пользовательские данные по ссылкам методом перебора.
Попробовав изменить одну букву в URL’e, мне любезно выдало чужой скриншот.
Для начала я попытался понять по какой маске генерируется ссылка вида http://prntscr.com/1npf9n
После небольших экспериментов, понял что маска скорее всего вида prntscr.com/1[a-z0–9] (после цифры 1 идет от 4 до 5 рандомных символов)
Так же я попробовал ссылки http://prntscr.com/login и http://prntscr.com/admin, по которым тоже увидел скриншоты.
Вероятнее всего алгоритм немного переписывался, и текущий алгоритм генерации ссылки устроен так, что исчерпав все варианты комбинаций, либо увеличится длина ссылки до 7 символов, либо маска станет prntscr.com/2[a-z0–9]
В процессе обнаружил одну особенность сервиса — он не хранит картинки у себя на сервере, а заливает их через API на imgur.com и imageshack.us
Меня терзало любопытство: «А можно ли скачать все скриншоты?»
И было решено написать небольшой скрипт. Сначала хотел писать на Python, но он не установлен на моем рабочем ноутбуке, зато под руку попался Denwer и PHP.
Просьба не пинать меня за мой код, который был написан за 5 минут на скорую руку. Он вполне рабочий.
Результат выполнения в браузере (как видно,
95% сгенерированных рандомных ссылок выдают скриншоты)
В итоге накачал целую кучу скриншотов, среди которых есть слишком личные фото людей, скриншоты кода, и много других интересных вещей.
UPD 2018: Поправил скрипт с учетом изменений произошедших на lightshot. Теперь снова работает.