开发者

PyQt QtWebkit: Visual analysis of the web page

For my task I need to analyze visual structure of the web page. I am using QtWebkit via PyQt as its an easy to use implementation of Webkit and easily available on all distros.

QtWebkit provides QWebElement objects which has geometry property and I can use it to obtain the location and dimensions of each DOM node. However I also need to subtract the margin, border and padding from the geometry returned.

I am using the styleProperty() method of QWebElement to get the border and margin properties as:

documentElement.开发者_高级运维styleProperty('border-bottom', QWebElement.ComputedStyle)

But it return's empty string denoting absence of the style method description here. Please help me how can I get the border, margin and padding so that I can subtract those from the geometry returned by geometry() method.

Update 1: It happens that I can get the CascadedStyle for some elements but the ComputedStyle remains empty for all elements.


I found with some hit and tries that border style is not used that much and I found other properties coming right.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜