使用PhantomJS从python3中的任何网站提取评论(.js文件中的评论)



我想从链接(WebCrawler)中提取注释。此代码来自此链接(Ctrl+u)。

 <div class="spot-im-frame-inpage" data-post-id="353493"></div><script type="text/javascript">
!function(t,e,n){function a(t){var a=e.createElement("script");a.type="text/javascript",a.async=!0,a.src=("https:"===e.location.protocol?"https":"http")+":"+n,(t||e.body||e.head).appendChild(a)}function o(){var t=e.getElementsByTagName("script"),n=t[t.length-1];return n.parentNode} var p=o();t.spotId="sp_6phY2k0C",t.parentElement=p,a(p)}(window.SPOTIM={},document,"//www.spot.im/launcher/bundle.js");

我可以进入bundle.js进行评论提取吗?

我读过phantomJs。我可以在python中使用phantomJs从任何javascript文件中抓取评论吗?(如上述代码.bundle.js所示)。如果是!怎样有打开.js文件的例子吗?

由于所有注释都绑定到类消息实体。我会让爬虫提取该类中每个元素的html。将phantomJS与python一起使用的最简单方法是通过Selenium或Ghostdrive。如果你不习惯使用python,那么我建议你使用node-harmman或casperjs之类的东西来浏览网站并获得评论。

最新更新