安装PyQt

下载PyQt(版本一定要对)

http://www.riverbankcomputing.com/software/pyqt/download

安装PyQt

 

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()

  

你可能感兴趣的:(qt)