Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

code: 'BAD_NETWORK' #28

Closed
techmexdev opened this issue Jun 28, 2017 · 3 comments
Closed

code: 'BAD_NETWORK' #28

techmexdev opened this issue Jun 28, 2017 · 3 comments

Comments

@techmexdev
Copy link

techmexdev commented Jun 28, 2017

This is the code I'm running:

const translate = require('google-translate-api');

translate('hola', { to: 'en' })
.then(res => { console.log(res.text) })
.catch(console.log);
@JukeboxRhino
Copy link
Collaborator

This will be fixed with a new npm release soon, it just hasn't been published yet. Stay updated for a new release.

@matheuss
Copy link
Owner

https://github.com/matheuss/google-translate-api/releases/tag/2.3.0 🙏

@extensionsapp
Copy link

Hey.
Google tightened the restrictions and now from a single IP address can make very few queries.
I added the use of a proxy server (IPv4, IPv6). Maybe my solution will help you.

https://github.com/extensionsapp/translatte

const translatte = require('translatte');

// Translate string to English using proxy
translatte('Вы говорите на русском?', {
    from: 'ru',
    to: 'en',
    agents: [
        'Mozilla/5.0 (Windows NT 10.0; ...',
        'Mozilla/4.0 (Windows NT 10.0; ...',
        'Mozilla/5.0 (Windows NT 10.0; ...'
    ],
    proxies: [
        'LOGIN:PASSWORD@192.0.2.100:12345',
        'LOGIN:PASSWORD@192.0.2.200:54321'
    ]
}).then(res => {
    console.log(res);
}).catch(err => {
    console.error(err);
});
// { text: 'Do you speak Russian?', 
//   from: { 
//     language: { 
//       didYouMean: false, 
//       iso: 'ru' 
//     }, 
//     text: { 
//       autoCorrected: false, 
//       value: '', 
//       didYouMean: false 
//     } 
//   },
//   raw: '' }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants