-

   rss_rss_hh_new

 - e-mail

 

 -

 LiveInternet.ru:
: 17.03.2011
:
:
: 51

:


[ ] . Nightmare.js

, 27 2017 . 14:21 +
, .

:


1. .
2. .
3. .

:


Casper.js, phantom.js, watir , . nightmare.js:

  1. .
  2. html5, .
  3. .


Nightmare electron, (BrowserWindow) Chromium.


  1. Nightmare electron , .
  2. , .
  3. Nightmare ( ), .


  1. , .
  2. . nightmare nightmare electron ( devapi Chromium). npm , ( realMouse , ).
  3. , , , .
  4. , , , ).
  5. nightmare , .
  6. . , .
  7. , webGL .
  8. , , . addEventListener + . , , , .


:

var Nightmare = require('nightmare');		
var nightmare = Nightmare({ show: true });

nightmare
  .goto('https://duckduckgo.com')
  .type('#search_form_input_homepage', 'github nightmare')
  .click('#search_button_homepage')
  .wait('#zero_click_wrapper .c-info__title a')
  .evaluate(function () {
    return document.querySelector('#zero_click_wrapper .c-info__title a').href;
  })
  .end()
  .then(function (result) {
    console.log(result);
  })
  .catch(function (error) {
    console.error('Search failed:', error);
  });


, . , , , , , , then . , , , :

const Nightmare = require('nightmare');		

(async ()=>{
let nightmare; 
try {
	nightmare = Nightmare({ show: true });
	await nightmare
  		.goto('https://duckduckgo.com')
 		 .type('#search_form_input_homepage', 'github nightmare')
		  .click('#search_button_homepage')
		  .wait('#zero_click_wrapper .c-info__title a');

	let siteData = await nightmare.evaluate(function () {
    		return document.querySelector('#zero_click_wrapper .c-info__title a').href;
  		});
	//    
} catch (error) {
	console.error(error);
	throw error;
} finally {
	await nightmare.end();
}
})();

? evaluate, , .

await nightmare.goto(.), Nightmare .


, . , , , html , pdf , . form input type=file. alert, prompt, confirm, .

nightmare


, , , , 100% try catch . wait(selector) html , , , , - - .


nightmare.js , . , , . , , .


-> Nigthmare.js
-> Electron

!
Original source: habrahabr.ru (comments, light).

https://habrahabr.ru/post/331752/

:  

: [1] []
 

:
: 

: ( )

:

  URL