我正在尝试从pdf远程提取文本。在
url为http://loc.gov/aba/publications/FreeLCC/A-text.pdf
我的代码如下
import urllib2
import PyPDF2
import io
URL = 'http://loc.gov/aba/publications/FreeLCC/A-outline.pdf'
remote_file = urllib2.urlopen(URL).read()
memory_file = io.BytesIO(remote_file)
read_pdf = PyPDF2.PdfFileReader(memory_file)
number_of_pages = read_pdf.getNumPages()
for i in range(0, number_of_pages):
pageObj = read_pdf.getPage(i)
page = pageObj.extractText()
print (page)
我得到一个403
HTTP错误。我做错什么了?在
Source
相关问题 更多 >
编程相关推荐