Chr*_*vén 8 css php python statistics
我想抓住一些博客并以编程方式分析他们的基于html和CSS的布局,以查看边栏是否位于主要内容的左侧或右侧,列数和宽度.
我怎么做最好的方法呢?我可以使用任何工具或库吗?
(我更喜欢Python或PHP的解决方案.)
看起来这可以通过PhantomJS来实现,使用如下的 Javascript:
phantom.viewportSize = { width: 1024, height: 768 };
var page = new WebPage();
page.open("http://mashable.com/", function(status) {
if (status === "success")
{
page.includeJs("https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js", function() {
var position = page.evaluate(function() {
return jQuery('#sidebar').position();
});
// Now position.left and position.top contains the
// position of the #sidebar element. Use other
// jQuery functions to calculate the relative position.
phantom.exit();
});
}
});
Run Code Online (Sandbox Code Playgroud)