{"action":"created","issue":{"url":"https://api.github.com/repos/graphcool/chromeless/issues/176","repository_url":"https://api.github.com/repos/graphcool/chromeless","labels_url":"https://api.github.com/repos/graphcool/chromeless/issues/176/labels{/name}","comments_url":"https://api.github.com/repos/graphcool/chromeless/issues/176/comments","events_url":"https://api.github.com/repos/graphcool/chromeless/issues/176/events","html_url":"https://github.com/graphcool/chromeless/issues/176","id":248218113,"number":176,"title":"Use-Case: Serverless Chrome In Local Mode","user":{"login":"neekolas","id":65710,"avatar_url":"https://avatars3.githubusercontent.com/u/65710?v=4","gravatar_id":"","url":"https://api.github.com/users/neekolas","html_url":"https://github.com/neekolas","followers_url":"https://api.github.com/users/neekolas/followers","following_url":"https://api.github.com/users/neekolas/following{/other_user}","gists_url":"https://api.github.com/users/neekolas/gists{/gist_id}","starred_url":"https://api.github.com/users/neekolas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/neekolas/subscriptions","organizations_url":"https://api.github.com/users/neekolas/orgs","repos_url":"https://api.github.com/users/neekolas/repos","events_url":"https://api.github.com/users/neekolas/events{/privacy}","received_events_url":"https://api.github.com/users/neekolas/received_events","type":"User","site_admin":false},"labels":[{"id":657225563,"url":"https://api.github.com/repos/graphcool/chromeless/labels/docs","name":"docs","color":"e99695","default":false},{"id":617721015,"url":"https://api.github.com/repos/graphcool/chromeless/labels/question","name":"question","color":"cc317c","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-08-06T00:49:57Z","updated_at":"2017-08-06T11:32:42Z","closed_at":null,"body":"Not sure if this is a case you guys have considered, but I don't see any reference to it in the open Issues or Readme. I have a modest sized (few million pages a day) crawler system that runs almost entirely in AWS Lambda. I would love to use Chromeless for its great APIs on top of Serverless Chrome, but I don't need all the fancy Websocket stuff of proxy mode since everything is already running inside a Lambda function. Creating a RPC from one Lambda to another seems overkill. \r\n\r\nIs it possible to use Chromeless in \"local\" mode with serverless-chrome acting as the local Chrome? Are there downsides or limitations to this approach? Will this be supported moving forward?"},"comment":{"url":"https://api.github.com/repos/graphcool/chromeless/issues/comments/320501280","html_url":"https://github.com/graphcool/chromeless/issues/176#issuecomment-320501280","issue_url":"https://api.github.com/repos/graphcool/chromeless/issues/176","id":320501280,"user":{"login":"adieuadieu","id":438848,"avatar_url":"https://avatars1.githubusercontent.com/u/438848?v=4","gravatar_id":"","url":"https://api.github.com/users/adieuadieu","html_url":"https://github.com/adieuadieu","followers_url":"https://api.github.com/users/adieuadieu/followers","following_url":"https://api.github.com/users/adieuadieu/following{/other_user}","gists_url":"https://api.github.com/users/adieuadieu/gists{/gist_id}","starred_url":"https://api.github.com/users/adieuadieu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adieuadieu/subscriptions","organizations_url":"https://api.github.com/users/adieuadieu/orgs","repos_url":"https://api.github.com/users/adieuadieu/repos","events_url":"https://api.github.com/users/adieuadieu/events{/privacy}","received_events_url":"https://api.github.com/users/adieuadieu/received_events","type":"User","site_admin":false},"created_at":"2017-08-06T11:32:42Z","updated_at":"2017-08-06T11:32:42Z","body":"Hi @neekolas yes of course! You're right that we haven't documented this very well, but Chromeless can be used within a Lambda function. The Chromeless Proxy [uses](https://github.com/graphcool/chromeless/blob/master/serverless/serverless.yml#L46) the [serverless-plugin-chrome](https://github.com/adieuadieu/serverless-chrome/tree/develop/packages/serverless-plugin) package for [Serverless](https://github.com/serverless/serverless). However, you can almost as easily go \"vanilla\" with the [@serverless-chrome/lambda](https://github.com/adieuadieu/serverless-chrome/tree/develop/packages/lambda) package. \r\n\r\nFor example (this is untested):\r\n\r\n```js\r\nconst launchChrome = require('@serverless-chrome/lambda')\r\nconst Chromeless = require('chromeless')\r\n\r\nmodule.exports.handler = function handler (event, context, callback) {\r\n  launchChrome({\r\n    flags: ['--window-size=1280x1696', '--hide-scrollbars'],\r\n  })\r\n    .then((chrome) => {\r\n      // Chrome is now running on localhost:9222\r\n\r\n      const chromeless = new Chromeless({\r\n        launchChrome: false,\r\n      })\r\n\r\n      chromeless\r\n        .goto('https://www.google.com')\r\n        .type('chromeless', 'input[name=\"q\"]')\r\n        .press(13)\r\n        .wait('#resultStats')\r\n        .evaluate(() => {\r\n          // this will be executed in headless chrome\r\n          const links = [].map.call(document.querySelectorAll('.g h3 a'), a => ({\r\n            title: a.innerText,\r\n            href: a.href,\r\n          }))\r\n          return JSON.stringify(links)\r\n        })\r\n        .then((urls) => {\r\n          chromeless\r\n            .close()\r\n            .then(chrome.kill) // https://github.com/adieuadieu/serverless-chrome/issues/41#issuecomment-317989508\r\n            .then(() => {\r\n              callback(null, urls)\r\n            })\r\n        })\r\n        .catch(callback)\r\n    })\r\n    .catch((error) => {\r\n      // Chrome didn't launch correctly\r\n      callback(error)\r\n    })\r\n}\r\n```\r\n"}}
{"actor":{"display_login":"adieuadieu"}}