Skip to content

Using Proxy #49

@3zzy

Description

@3zzy
google.requestOptions = {
  proxy: 'http://12.41.141.10:8080',
  timeout: 30000,
  localAddress: '127.0.0.1',
  jar: true,
  headers: {
    'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
    'Accept-Encoding': 'gzip, deflate',
    'Accept-Language': 'en;q=0.5',
    'Cache-Control': 'max-age=0',
    'Connection': 'keep-alive',
    'DNT': 1,
    'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.75 Safari/537.36'
  }
}

If I use a proxy and some other headers, I just get this error:

Error: Error on response:Error: connect EADDRNOTAVAIL 12.41.141.10:8080 - Local (127.0.0.1:58302) : undefined
    at Request._callback (/Users/john/Work/www/myapp/node_modules/google/lib/google.js:98:16)
    at self.callback (/Users/john/Work/www/myapp/node_modules/request/request.js:186:22)
    at emitOne (events.js:96:13)
    at Request.emit (events.js:188:7)
    at Request.onRequestError (/Users/john/Work/www/myapp/node_modules/request/request.js:845:8)
    at emitOne (events.js:96:13)
    at ClientRequest.emit (events.js:188:7)
    at Socket.socketErrorListener (_http_client.js:310:9)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:188:7)
/Users/john/Work/www/myapp/scrape.js:25
  for (var i = 0; i < res.links.length; ++i) {
                         ^

TypeError: Cannot read property 'links' of null
    at /Users/john/Work/www/myapp/scrape.js:25:26
    at Request._callback (/Users/john/Work/www/myapp/node_modules/google/lib/google.js:98:7)
    at self.callback (/Users/john/Work/www/myapp/node_modules/request/request.js:186:22)
    at emitOne (events.js:96:13)
    at Request.emit (events.js:188:7)
    at Request.onRequestError (/Users/john/Work/www/myapp/node_modules/request/request.js:845:8)
    at emitOne (events.js:96:13)
    at ClientRequest.emit (events.js:188:7)
    at Socket.socketErrorListener (_http_client.js:310:9)
    at emitOne (events.js:96:13)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions