PhantomJs返回浏览器返回的其他内容

时间:2017-04-20 20:20:36

标签: web-scraping phantomjs

我使用此脚本从openload.com获取直接链接

var page = require('webpage').create(),
system = require('system');

phantom.addCookie({
  'name'     : '__cfduid',   /* required property */
  'value'    : 'd4f5181dc0289c86a3879d814f4482bca1492014866',  /* required property */
  'domain'   : 'openload.co',        /* required property */  
});
phantom.addCookie({
  'name'     : '_csrf',   /* required property */
  'value'    : 'c24ad4f1b31ea846a3bbc9b7e73481aa655d398b2a98e3988e2cb39d3ff6037aa%3A2%3A%7Bi%3A0%3Bs%3A5%3A%22_csrf%22%3Bi%3A1%3Bs%3A32%3A%22NifzNtDalPxy9y4GCn5dvm73eJCt1umM%22%3B%7D',  /* required property */
  'domain'   : 'openload.co',        /* required property */  
});
phantom.addCookie({
  'name'     : '_olbknd',   /* required property */
  'value'    : 'w10',  /* required property */
  'domain'   : 'openload.co',        /* required property */  
});
phantom.addCookie({
  'name'     : 'PHPSESSID',   /* required property */
  'value'    : 'vipbceuuvemjfcbdfd11a37vc6',  /* required property */
  'domain'   : 'openload.co',        /* required property */  
});
phantom.addCookie({
  'name'     : '3fda7f26bf1713215fc076be8dd63bbc',   /* required property */
  'value'    : 'd84e28dc7cd6edec29b07ec5f17328373c40a646e14f51850081c71cad6e5a65a%3A2%3A%7Bi%3A0%3Bs%3A32%3A%223fda7f26bf1713215fc076be8dd63bbc%22%3Bi%3A1%3Bs%3A6%3A%22Qq1hjz%22%3B%7D',  /* required property */
  'domain'   : 'openload.co',        /* required property */  
});
phantom.addCookie({
  'name'     : '_identity',   /* required property */
  'value'    : 'cb9453b8d2ca39f55cb98ec19bab68aa94d82074958f60a73967a307df2e6b5da%3A2%3A%7Bi%3A0%3Bs%3A9%3A%22_identity%22%3Bi%3A1%3Bs%3A91%3A%22%5B%220ae379d8d3d9c628%22%2C%22%242y%2410%24Un6%2FIxHushWyPqNzhdCGY.00EjwdeahINQYhhfX2d3u9tdgvbbr4C%22%2C2592000%5D%22%3B%7D',  /* required property */
  'domain'   : 'openload.co',        /* required property */  
});

page.onLoadFinished = function() {
setTimeout(function(){
var ret=page.evaluate(function() {
$("#downloadTimer").click();

    return $('#streamurl').text();
  });

        console.log(ret);
    phantom.exit();
}, 1000);

};
page.open(system.args[1]);

浏览器中的streamurl值类似于9ABK60WJ38c~1492801695~95.211.0.0~K82Yxw28 但是什么幻影回归就像├½┬┤├à#├ö┬«∩╛á┬¥├è┬╕∩┐ñs├é┬¬∩┐ª┬┬┬┬6∩┐èHM┬å┬┬┬¢q ∩┐ñ├½├¢¥┬╖F┬Ü┬¬∩╛╡├┬æ├»∩┐╣!┬╜┬╢∩┐▒

我不知道我做错了什么

1 个答案:

答案 0 :(得分:0)

我一直在学习phantomjs很短的时间。代码应该是这样的,以获得streamurl的值:

var page = require('webpage').create(),
system = require('system');

phantom.addCookie({
  'name'     : '__cfduid',   /* required property */
  'value'    : 'd4f5181dc0289c86a3879d814f4482bca1492014866',  /* required property */
  'domain'   : 'openload.co',        /* required property */  
});
phantom.addCookie({
  'name'     : '_csrf',   /* required property */
  'value'    : 'c24ad4f1b31ea846a3bbc9b7e73481aa655d398b2a98e3988e2cb39d3ff6037aa%3A2%3A%7Bi%3A0%3Bs%3A5%3A%22_csrf%22%3Bi%3A1%3Bs%3A32%3A%22NifzNtDalPxy9y4GCn5dvm73eJCt1umM%22%3B%7D',  /* required property */
  'domain'   : 'openload.co',        /* required property */  
});
phantom.addCookie({
  'name'     : '_olbknd',   /* required property */
  'value'    : 'w10',  /* required property */
  'domain'   : 'openload.co',        /* required property */  
});
phantom.addCookie({
  'name'     : 'PHPSESSID',   /* required property */
  'value'    : 'vipbceuuvemjfcbdfd11a37vc6',  /* required property */
  'domain'   : 'openload.co',        /* required property */  
});
phantom.addCookie({
  'name'     : '3fda7f26bf1713215fc076be8dd63bbc',   /* required property */
  'value'    : 'd84e28dc7cd6edec29b07ec5f17328373c40a646e14f51850081c71cad6e5a65a%3A2%3A%7Bi%3A0%3Bs%3A32%3A%223fda7f26bf1713215fc076be8dd63bbc%22%3Bi%3A1%3Bs%3A6%3A%22Qq1hjz%22%3B%7D',  /* required property */
  'domain'   : 'openload.co',        /* required property */  
});
phantom.addCookie({
  'name'     : '_identity',   /* required property */
  'value'    : 'cb9453b8d2ca39f55cb98ec19bab68aa94d82074958f60a73967a307df2e6b5da%3A2%3A%7Bi%3A0%3Bs%3A9%3A%22_identity%22%3Bi%3A1%3Bs%3A91%3A%22%5B%220ae379d8d3d9c628%22%2C%22%242y%2410%24Un6%2FIxHushWyPqNzhdCGY.00EjwdeahINQYhhfX2d3u9tdgvbbr4C%22%2C2592000%5D%22%3B%7D',  /* required property */
  'domain'   : 'openload.co',        /* required property */  
});

page.settings.userAgent = 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.120 Safari/537.36';

page.onInitialized = function(){
  page.evaluate(function(){
    delete window._phantom;
    delete window.callPhantom;
  });
};

page.onLoadFinished = function(){
  setTimeout(function(){
    var ret=page.evaluate(function(){
      $("#downloadTimer").click();
      return $('#streamurl').text();
    });
    console.log(ret);
    phantom.exit();
  }, 1000);
};

page.open(system.args[1]);