Scalescrape Release 0.1.0

I've just released a Scala web scraping library called Scalescrape built on top of Scalext.

It provides a DSL to scrape websites, using internally Akka actors and the Spray client library.

Here's a couple of example of the DSL in action:

private def login(username: String, password: String) =
  scrape {
    postForm(website.loginForm(username, password)) { response =>
      response.asHtml { doc =>
        doc.$("title").text match {
          case "Login error" => complete(LoginFailed)
          case _ =>
            cookies { cookies =>
              savedCookies = cookies
              complete(LoggedIn)
            }
        }
      }
    }
  }

private def updateAccountEmail(newEmail: String) =
  scrape { 
    withCookies(savedCookies) {
      get(website.homePage) { response =>
        response.asHtml { doc =>
          val currentEmail = doc.$("#account-email").text
          if (currentEmail != newEmail) {
            post(website.updateAccountEmailRequest(newEmail)) { response =>
              response.asJson { jsonResponse =>
                (jsonResponse \ "error") match {
                  case JString(message) => fail
                  case _                => complete(EmailUpdated)
                }
              }
            }
          } else complete(EmailUpToDate)
        }
      }
    }
  }

To find out more read the explained example and documentation on GitHub: https://github.com/bfil/scalescrape