Skip to content

Commit

Permalink
improve example
Browse files Browse the repository at this point in the history
  • Loading branch information
christian-fei committed Dec 29, 2019
1 parent 864f3ad commit 0bcaced
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
12 changes: 5 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,20 @@ spin up a puppeteer instance (with [mega-scraper](https://github.com/christian-f

```js
#!/usr/bin/env node
const megaScraper = require('mega-scraper')
const translate = require('.')
const translate = require('free-google-translate-with-puppeteer')

main()
.then(() => process.exit(0))

async function main () {
const browser = await megaScraper.browser.createBrowser({ headless: true })
const toTranslate = [{
text: 'ciao, come stai?', from: 'it', to: 'en', browser
text: 'ciao, come stai?', from: 'it', to: 'en'
}, {
text: 'hey', from: 'en', to: 'es', browser
text: 'hey', from: 'en', to: 'es'
}, {
text: 'one apple a day keeps the doctor away', from: 'en', to: 'de', browser
text: 'one apple a day keeps the doctor away', from: 'en', to: 'de'
}, {
text: 'one apple a day keeps the doctor away', to: 'de', browser
text: 'one apple a day keeps the doctor away', to: 'de'
}]
for (const params of toTranslate) {
console.log(`Translating "${params.text}" from "${params.from || 'auto'}" to "${params.to}"`)
Expand Down
4 changes: 2 additions & 2 deletions example.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#!/usr/bin/env node
const megaScraper = require('mega-scraper')
const { browser: { createBrowser } } = require('mega-scraper')
const translate = require('.')

main()

async function main () {
const browser = await megaScraper.browser.createBrowser({ headless: true })
const browser = await createBrowser({ headless: true })
const toTranslate = [{
text: 'ciao, come stai?', from: 'it', to: 'en', browser
}, {
Expand Down

0 comments on commit 0bcaced

Please sign in to comment.