标签:blog http io ar os sp on 文件 div
下载PyQt(版本一定要对)
http://www.riverbankcomputing.com/software/pyqt/download
import sys,urllib2 from HTMLParser import HTMLParser from PyQt4.QtCore import * from PyQt4.QtGui import * from PyQt4.QtWebKit import * class Render(QWebPage): def __init__(self, url): self.app = QApplication(sys.argv) QWebPage.__init__(self) self.loadFinished.connect(self._loadFinished) self.mainFrame().load(QUrl(url)) self.app.exec_() def _loadFinished(self, result): self.frame = self.mainFrame() self.app.quit() url = ‘http://888.qq.com/v1.0/buy/jczq.shtml#spf_gg‘ r = Render(url) html = r.frame.toHtml() print html.toUtf8() # 将执行后的代码写入文件中 f = open(‘./test.txt‘,‘w‘) f.write(html.toUtf8()) f.close()
标签:blog http io ar os sp on 文件 div
原文地址:http://www.cnblogs.com/zhangmy/p/4153375.html