mirror of
https://github.com/anatolykopyl/dochunt.git
synced 2026-03-26 12:54:41 +00:00
⚡️ Catching not images
Also got rid of the sleep
This commit is contained in:
2
main.py
2
main.py
@@ -79,7 +79,7 @@ while True:
|
|||||||
photos_saved += 1
|
photos_saved += 1
|
||||||
save_photo(image_url)
|
save_photo(image_url)
|
||||||
|
|
||||||
sleep(1)
|
#sleep(1)
|
||||||
|
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
c.print(' Goodbye!', style='blue')
|
c.print(' Goodbye!', style='blue')
|
||||||
|
|||||||
@@ -7,7 +7,8 @@ def detect(url):
|
|||||||
response = requests.get(url)
|
response = requests.get(url)
|
||||||
try:
|
try:
|
||||||
img = Image.open(io.BytesIO(response.content))
|
img = Image.open(io.BytesIO(response.content))
|
||||||
except OSError:
|
string = pytesseract.image_to_string(img, lang='rus', timeout=30).lower()
|
||||||
return ''
|
except OSError: # Happens when whatever we get is not an image and cant be opened as such
|
||||||
|
string = ''
|
||||||
|
|
||||||
return pytesseract.image_to_string(img, lang='rus', timeout=30).lower()
|
return string
|
||||||
|
|||||||
Reference in New Issue
Block a user