python cefpython 想在加载完毕后,获取网页的html 但一直空白

新手上路,请多包涵

class Visitor(object):

def Visit(self, value):
    print("This is the HTML source:")
    print(value)

class LoadHandler(object):

def OnLoadingStateChange(self,browser,is_loading,**_):
    if not is_loading:
        pass

def OnLoadEnd(self,browser,frame,http_code):
    ''''加载完成 打印结果'''
    sv = Visitor();
    frame.GetSource(sv);
    print "end";
    

先上代码了。 我在CEF加载完毕事件后,想得到页面html,但一直没得到结果,为什么?求解

阅读 5.4k
1 个回答

Must keep a strong reference to the StringVisitor object during the visit.

change:

sv = Visitor();

to:

self.sv = Visitor()
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题