mirror of
https://github.com/anatolykopyl/dochunt.git
synced 2026-03-26 21:04:43 +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
|
||||
save_photo(image_url)
|
||||
|
||||
sleep(1)
|
||||
#sleep(1)
|
||||
|
||||
except KeyboardInterrupt:
|
||||
c.print(' Goodbye!', style='blue')
|
||||
|
||||
@@ -7,7 +7,8 @@ def detect(url):
|
||||
response = requests.get(url)
|
||||
try:
|
||||
img = Image.open(io.BytesIO(response.content))
|
||||
except OSError:
|
||||
return ''
|
||||
string = pytesseract.image_to_string(img, lang='rus', timeout=30).lower()
|
||||
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