微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何阅读波斯语pdf并抓取其内容?

如何解决如何阅读波斯语pdf并抓取其内容?

我正在尝试阅读这个波斯语 pdf,但结果没有很好地解码。我也试过 utf-16 或 utf-32,但没有产生可读的结果。我想在表中获取波斯日期。 尝试了其他库,但没有提取出好的文本。

 urlpdf="https://www.codal.ir/Reports/DownloadFile.aspx?id=LG5QhAhMbfl2DrQQQaQQQ%2bkR9nMQ%3d%3d"
    response = requests.get(urlpdf,verify=False,timeout=5)
with io.BytesIO(response.content) as f:
    #print(response.content)
    pdf = PdfFileReader(f)
    #print(pdf)
    information = pdf.getDocumentInfo()
    number_of_pages = pdf.getNumPages()
    txt = f"""
    Author: {information.author}
    Creator: {information.creator}
    Producer: {information.producer}
    Subject: {information.subject}
    Title: {information.title}
    Number of pages: {number_of_pages}
    """
    # Here the Metadata of your pdf
    print(txt)
    # numpage for the number page
    numpage=0
    page = pdf.getPage(numpage)
    page_content = page.extractText()+"\n"
    # print the content in the page 20 
    g=open("extract.txt",'w',encoding='UTF-8',)
    g.write(page_content)
    g.close
    print(page_content)

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。