开发者

NoneType in QWebFrame Object childFrames() List

开发者 https://www.devze.com 2023-04-02 06:12 出处:网络
I am trying to access a child frame inside a web page using python qt webkit. The childFrames() result an empty list with NoneType in front of the list, how do I go directly to the second entity sinc

I am trying to access a child frame inside a web page using python qt webkit.

The childFrames() result an empty list with NoneType in front of the list, how do I go directly to the second entity since I can't use fr.childFrames()[1][1] : It will throw TypeError: 'QWebFrame' object does not support indexing.

These are part of the code:

fr = self.page().mainFrame().childFrames()
for f in fr:
    print f.frameName()

will output the frame title of each frame, but if :

fr = self.page().mainFrame().childFrames()
print fr

will output

[]
[<PyQt4.QtWebKit.QWebFrame object at 0x14a1200>, <PyQt4.QtWebKit.QWebFrame object at 0x14a1290>, <PyQt4.QtWebKit.QWebFrame object at 0x14a1320>, <PyQt4.QtWebKit.QWebFrame object at 0x14a13b0>]

If I go directly like this :

print fr[1].frameName()

Will throw IndexError first (The list with no content), and then will give 开发者_如何转开发me the title of the frame from the second list.

Is this an expected behaviour? if so, how do I get directly to the frames in the second list.


Your output seems to be two lists - the first is empty, the second contains QWebFrames.

What does print fr[1][0].frameName() give you? It should return the frame name for <PyQt4.QtWebKit.QWebFrame object at 0x14a1200>.

0

精彩评论

暂无评论...
验证码 换一张
取 消