'Parse number from an image pytesseract

I am trying to parse a number from an image. Here's an example of the images enter image description here

I tried first to extract all the text to have a look at the final result but the code didn't recognize the desired number This is my try

from PyPDF2 import PdfFileWriter, PdfFileReader
import fitz, pytesseract, os, re
import cv2


def readNumber(img):
    img = cv2.imread(img)
    gry = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
    txt = pytesseract.image_to_string(gry)
    return txt

I am trying to parse the number after the slash in the second line. Here the expected is 502630

Here's another sample picture that Ahx's code failed to parse the number from it

enter image description here



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source