mirror of
https://github.com/colemata2794/kickme.git
synced 2024-09-20 06:46:21 +08:00
25 lines
695 B
JavaScript
25 lines
695 B
JavaScript
|
|
module.exports = (title) => {
|
|
const Nightmare = require('nightmare');
|
|
const nightmare = Nightmare({ show: true });
|
|
if(!title) {
|
|
return 'please input title';
|
|
}
|
|
let lirik = 'lirik '+process.argv[2];
|
|
return new Promise((resolve, reject) => {
|
|
nightmare
|
|
.goto(`https://www.google.com/search?q=${lirik.replace(/ /g,'+')}`)
|
|
.wait('#resultStats')
|
|
.click('h3.r a')
|
|
.evaluate(() => document.querySelectorAll('.col-lirik.lyrics-body')[0].innerText)
|
|
.end()
|
|
.then((dataLyrics) => {
|
|
resolve(dataLyrics);
|
|
return;
|
|
})
|
|
.catch((error) => {
|
|
reject('Search failed');
|
|
return 'Search failed:', error;
|
|
});
|
|
})
|
|
} |