标签:
本文介绍下pdf页面的爬取,需要借助pdfminer模块
demo一般流程:
1)设置url
url = ‘http://www.------‘ + ‘.PDF‘
2)requests模块获取url
import requests
r = requests.get(inner_url)
3)写入.pdf文件
myFile = open("PDF/" + i[u‘associateAnnouncement‘] + ‘.pdf‘, "wb") myFile.write( r.content ) myFile.close()
4)引入pdfminer模块
import pdfminer
5)BeautifulSoup解析html
from bs4 import BeautifulSoup html = open(‘PDF/1202268749.html‘).read()
未完待续,先睡觉,pdfminer把pdf页面解析成html页面,然后beautifulsoap解析html页面即可。
标签:
原文地址:http://www.cnblogs.com/rongyux/p/5513811.html