1

I'm new to PhantomJS and not very good with Javascript to be honest. I'm looking to take a snapshot of a given website but only the selected dom element. So command wise it would look a little like

phantomjs http://fabieno.com #nav

And it would take a picture of the nav bar. Or whatever the selector selects. I guess it multiple existences exists then multiple snapshots would be necessary. Only problem is being so new it leaves me with a big ? in my head. Any help you guys could provide would be greatly appreciated.

From my research I have only really found. https://gist.github.com/n1k0/1501173

But I am unsure how it works or if it does want I am asking.

Kind regards,

Fab

4

1 回答 1

0

由于您实际上应该只有一个id名为的属性nav,因此您可能希望对类执行此操作。在这种情况下,请查看getElementsByClassName,您想要获得的是所有导航元素的集合,并通过它们循环执行您需要的操作。有关详细信息,请参阅此JS:使用 Array.forEach 迭代 getElementsByClassName 的结果

于 2013-05-22T15:08:57.957 回答