PyQt4字符编码:\'ascii\'编解码器无法对字符进行编码

问题描述

|| 尝试使用以下脚本加载页面,以便我可以执行javascript来访问页面。我想登录并查看生成的页面(https://www.thomsononeim.com/v-hom.asp),该页面也已执行Javascript。在Python 2.7中,出现此错误:   追溯(最近一次通话):   文件\“ C:/ Python27 / Sample   程序/愚蠢Test.py \“,第22行,在          打印html UnicodeEncodeError:\'ascii \'编解码器无法编码字符   u \'\\ xa9 \'在位置8273:序数不   范围内(128) 这是代码:
from __future__ import unicode_literals
from __future__ import print_function
from __future__ import division
import sys
from PyQt4.QtGui import *
from PyQt4.QtCore 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 = \'https://www.thomsononeim.com/s-log_in.asp\'
r = Render(url)
html = r.frame.toHtml()
print(html)
    

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)