# -*- coding: utf-8 -*-"""Created on Tue Jun 14 13:01:58 2016@author: """import urllib2import cookielibimport pdfkitcj = cookielib.LWPCookieJar()opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))urllib2.install_opener(opener)url = "https://www.taobao.com/"req = urllib2.Request(url)''' 保存html到本地'''operate = opener.open(req)msg = operate.read()document = 'D://1.html' file_ = open(document,'w') file_.write(msg)file_.close()path_wk = r'C:\Python27\wkhtmltopdf\bin\wkhtmltopdf.exe'config = pdfkit.configuration(wkhtmltopdf = path_wk)'''保存pdf到本地'''pdfkit.from_url(url, r'D:\are you coding\pdf\taobao.pdf', configuration=config)
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请
点击举报。