Last active
March 6, 2024 14:57
-
-
Save nsdevaraj/57ca722544e06eebe20881eea5e02e72 to your computer and use it in GitHub Desktop.
get console log to file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
count=840 | |
declare -i count | |
echo "Prepare to launch" | |
while [[ $count -gt 99 ]]; do | |
sleep 1 | |
echo "$count" | |
node tra.js "0"$count | |
count=$count-1 | |
done | |
sleep 1 | |
echo "Lift Off" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
awk 'FNR==2{print;nextfile}' *.txt > output_file |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const puppeteer = require('puppeteer'); | |
const fs = require('node:fs/promises'); | |
const arg = process.argv.slice(2); | |
(async () => { | |
const browser = await puppeteer.launch({headless: true}); | |
const page = await browser.newPage() | |
let number = arg[0] | |
let url ='https://www.thirukkural.net/en/kural/kural-'+number+'.html' | |
await page.goto(url, { waitUntil: 'networkidle2' }); | |
await page.addScriptTag({ path: "jquery-1.9.1.js" }) | |
// execute standard javascript in the context of the page. | |
const previousData = await page.evaluate(() => { | |
let storyArr = []; | |
var languages = ["[lang=hi]", "[lang=te]", "[lang=kn]", "[lang=ml]", "[lang=si]", "[lang=zh]", "[lang=ms]", "[lang=ko]", "[lang=ru]", "[lang=fr]", "[lang=de]", "[lang=sv]", "[lang=la]", "[lang=pl]","[lang=ar]"] | |
for (var i = 0; i < languages.length; i++) { | |
var lines = $(languages[i])[0].innerHTML.split('<br>') | |
for (var j = 0; j < lines.length; j++) { | |
i == languages.length - 1 ? line = lines[j] : line = lines[j].replace(/(\(.+)\W/i, ' ') | |
if (line.indexOf("span") == -1) storyArr.push(line) | |
} | |
} | |
return storyArr; | |
}) | |
await fs.writeFile('/Users/devarajns/Downloads/out/'+number+'.txt', previousData.join("\n"), err => { | |
if (err) { | |
console.error(err); | |
} else { | |
// file written successfully | |
} | |
}); | |
await browser.close() | |
})(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment