Я могу что то написать в императивном стиле, все в одном файле, 100500 функций. Да может быть будет что то работать, но за хорошее инженерное решение это не сойдет.
Хотя бы научиться этому, а потом уже браться за полезные инструменты в виде какие то зависимостей, те же фреймворки.
var links = [];
var casper = require('casper').create();
function getLinks() {
var links = document.querySelectorAll('h3.r a');
return Array.prototype.map.call(links, function(e) {
return e.getAttribute('href');
});
}
casper.start('http://google.fr/', function() {
// Wait for the page to be loaded
this.waitForSelector('form[action="/search"]');
});
casper.then(function() {
// search for 'casperjs' from google form
this.fill('form[action="/search"]', { q: 'casperjs' }, true);
});
casper.then(function() {
// aggregate results for the 'casperjs' search
links = this.evaluate(getLinks);
// now search for 'phantomjs' by filling the form again
this.fill('form[action="/search"]', { q: 'phantomjs' }, true);
});
casper.then(function() {
// aggregate results for the 'phantomjs' search
links = links.concat(this.evaluate(getLinks));
});
casper.run(function() {
// echo results in some pretty fashion
this.echo(links.length + ' links found:');
this.echo(' - ' + links.join('\n - ')).exit();
});
$ casperjs googlelinks.js
20 links found:
- https://github.com/casperjs/casperjs
- https://github.com/casperjs/casperjs/issues/2
- https://github.com/casperjs/casperjs/tree/master/samples
- https://github.com/casperjs/casperjs/commits/master/
- http://www.facebook.com/people/Casper-Js/100000337260665
- http://www.facebook.com/public/Casper-Js
- http://hashtags.org/tag/CasperJS/
- http://www.zerotohundred.com/newforums/members/casper-js.html
- http://www.yellowpages.com/casper-wy/j-s-enterprises
- http://local.trib.com/casper+wy/j+s+chinese+restaurant.zq.html
- http://www.phantomjs.org/
- http://code.google.com/p/phantomjs/
- http://code.google.com/p/phantomjs/wiki/QuickStart
- http://svay.com/blog/index/post/2011/08/31/Paris-JS-10-%3A-Introduction-%C3%A0-PhantomJS
- https://github.com/ariya/phantomjs
- http://dailyjs.com/2011/01/28/phantoms/
- http://css.dzone.com/articles/phantom-js-alternative
- http://pilvee.com/blog/tag/phantom-js/
- http://ariya.blogspot.com/2011/01/phantomjs-minimalistic-headless-webkit.html
- http://www.readwriteweb.com/hack/2011/03/phantomjs-the-power-of-webkit.php
<li code="код" caption="то, что отображается">Техт</li>
$('ul li').click(() => {
var code=$(this).attr('code');
var caption=$(this).attr('caption');
//...
})
$("#autocomplete_search_box").keyup()
window.addEventListener('DOMContentLoaded', preloaderShow, false);
window.addEventListener('load', preloaderHide);
function preloaderShow() {
alert('Контента еще нет');
}
function preloaderHide() {
alert('Весь контент загружен');
}
page.render()
стоит внутри window.setTimeout()
this.waitForSelector('form[action="/search"]');
var casper = require('casper').create({
viewportSize: {
width : 800, /* Здесь можно указать требуемое */
height: 600 /* разрешение очка браузера */
}
});
casper.start('http://www.google.nl/', function() {
this.capture('google.png');
});
casper.run();
Можно повторить со всеми нужными вам разрешениями. var arr = [
'img/04_slider_food/1_fast_food//01_Chicken Burger.jpg',
'img/04_slider_food/1_fast_food//02_Chicken Pizza.jpg',
'img/04_slider_food/1_fast_food//03_Beef Burger.jpg',
'img/04_slider_food/1_fast_food//07_Rolls.jpg',
'img/04_slider_food/1_fast_food//08_Wendy’s Dave’s Hot ‘N Juicy.jpeg'
];
var res = arr.map(uri => uri.replace(/^([\w\d\s_]*\/)+\d{2}_/,''));
console.log(JSON.stringify(res, null, 4));
[
"Chicken Burger.jpg",
"Chicken Pizza.jpg",
"Beef Burger.jpg",
"Rolls.jpg",
"Wendy’s Dave’s Hot ‘N Juicy.jpeg"
]
что jsx-скрипт распарсивается какой-то библиотекой написаной на стандартном javascript и транслирует в него же...
Может есть живой движок на примете с биндингами для node.js?