【问题标题】:How to parse page that uses HTML5 local storage?如何解析使用 HTML5 本地存储的页面?
【发布时间】:2014-11-05 11:12:57
【问题描述】:

提前对不起我的英语) 我有一个任务 - 为站点编写一个解析器,但他的所有页面都将输入的数据保存在 HTML5 本地存储中。真的要模拟点击页面上的图像并检索点击后保存到数据存储中的所有变量值吗?例如,使用 NodeJS + jsdom 之类的解析器(https://github.com/tmpvar/jsdom)?或者我可以为此使用一些替代技术? 谢谢!

【问题讨论】:

    标签: node.js parsing local-storage


    【解决方案1】:

    听起来您正在尝试使用大量 javascript 解析网站。您可以使用 phontom 来模拟用户行为。考虑你想使用节点。然后你可以使用 Node-Phontom 来做到这一点。

    var phantom=require('node-phantom');
    phantom.create(function(err,ph) {
      return ph.createPage(function(err,page) {
        return page.open("you/url/", function(err,status) {
          console.log("opened site? ", status);
          page.includeJs('http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js', function(err) {
            //jQuery Loaded.
            //Settimeout to wait for a bit for AJAX call.
            setTimeout(function() {
              return page.evaluate(function() {
                //Get what you want from the page
                //e.g. localStorage.getItem('xxx');
            }, 5000);
          });
        });
      });
    });
    

    Here is phontom.

    Here is node-phontom.

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-05-21
      • 2011-10-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-11
      • 1970-01-01
      相关资源
      最近更新 更多