خرید بک لینک

Vote count: 0

Good day. I'm having some trouble in getting the content of a pdf page, which is show in a url like this. I need to get some information that the page text has.

https://web.site.com/printRel.aspx?rel=usermov&cod=1

I've been trying a lot of solutions even from here, but none of those worked so far. The best result that I've foud was the following one, but it is giving an error.

Can anyone assist me fixing this or showing a best solution for this kind of operation?

class MyAdapter(HTTPAdapter):
    def init_poolmanager(self, coections, maxsize, block=False):
     self.poolmanager = PoolManager(num_pools=coections,
                                    maxsize=maxsize,
                                    block=block,
                                    ssl_version=ssl.PROTOCOL_TLSv1)

def accessPages():
    s = requests.Session()
    s.mount('https://', MyAdapter())
    r = s.get('https://web.site.com/printRel.aspx?rel=usermov&cod=1')
    return r.text


def convert_pdf_to_txt(r):
    writer = PdfFileWriter()

    remoteFile = r + "%%EOF"
    memoryFile = StringIO(remoteFile)
    pdfFile = PdfFileReader(memoryFile)

    for pageNum in xrange(0, 1):
            currentPage = pdfFile.getPage(pageNum)
            #currentPage.mergePage(watermark.getPage(0))
            writer.addPage(currentPage)

    outputStream = open("output.pdf","wb")
    writer.write(outputStream)
    outputStream.close()

Upon executing this I get the following error message

Traceback (most recent call last):
  File "mov_user_scratch.py", line 69, in <module>
    main(sys.argv)
  File "mov_user_scratch.py", line 66, in main
    convert_pdf_to_txt(r)
  File "mov_user_scratch.py", line 53, in convert_pdf_to_txt
    pdfFile = PdfFileReader(memoryFile)
  File "/usr/lib/python2.7/site-packages/pyPdf/pdf.py", line 374, in __init__
    self.read(stream)
  File "/usr/lib/python2.7/site-packages/pyPdf/pdf.py", line 711, in read
    startxref = int(line)
ValueError: invalid literal for int() with base 10: '</html>'

asked 1 min ago

برچسب: نویسنده: استخدام کار تاريخ: دوشنبه 8 شهريور 1395 ساعت: 4:51

صفحه بندی