google-translate-api icon indicating copy to clipboard operation
google-translate-api copied to clipboard

Different BAD_NETWORK issue?

Open skygragon opened this issue 7 years ago • 1 comments
trafficstars

node: 8.1.4 npm: 5.3.0

{ Error: unable to get local issuer certificate
    at /Users/xxx/test/nodejs/node_modules/google-translate-token/index.js:103:25
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:169:7)
  code: 'BAD_NETWORK',
  message: 'unable to get local issuer certificate' }

skygragon avatar Jan 04 '18 05:01 skygragon

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:[email protected]:12345',
        'LOGIN:[email protected]: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: '' }

extensionsapp avatar Sep 24 '18 19:09 extensionsapp