vitalets / google-translate-api

A free and unlimited API for Google Translate :dollar: :no_entry_sign:
MIT License
920 stars 117 forks source link

Is it possible to use shadowsocks/proxy? #108

Open shadowsocksquestions opened 1 year ago

shadowsocksquestions commented 1 year ago

I need to use shadowsocks to connect to Google - I can navigate to Google translate in the browser using the proxy, but I can't get it working in the node program. I have tried both the recommended http-proxy-agent and also tried socks-proxy-agent as well as few others, but can't get nothing to work

In the shadowsocks logs, it seems the proxy isn't even attempting to connect to the Shadowsocks client

const translate = require('@vitalets/google-translate-api');
//const createHttpProxyAgent = require ('http-proxy-agent');
const {SocksProxyAgent} = require('socks-proxy-agent');

const info = {
    hostname: '127.0.0.1',
  port: '12345'

};
const agent = new SocksProxyAgent(info);

// const agent = createHttpProxyAgent('http://127.0.0.1:47283');
console.log(agent)

async function tr(){
    console.log("sending...")
    const res = await translate('Привет, мир!', {
        to: 'en',
        fetchOptions: { agent },
      });
      console.log(res)
}

tr()

Does anyone know how to get this working? I would appreciate anyone who has any tips

Thanks

vitalets commented 1 year ago

Does the example from socks-proxy-agent repo work for you?