 {CompositeDisposable} = require 'atom'
+google = require 'google'
+request = require 'request'
+cheerio = require 'cheerio'
 
 # Returns the code from the first accepted SO answer
 # from the provided URLs to SO pages.

# a StackOverflow page
scrapeStackOverflow = (soLink) ->
  return new Promise (resolve, reject) ->
    request = require 'request'
    request soLink, (error, response, body) ->
      if !error && response.statusCode == 200
        cheerio = require 'cheerio'
        $ = cheerio.load body
        snippet = $('div.accepted-answer pre code').text()
        if snippet == ""

          atom.notifications.addSuccess "Got snippet!"
          editor.insertText(snippet)
        , (err) ->
          atom.notifications.addError err.reason
      , (err) ->
        atom.notifications.addError err.reason
