Play Framework - 从其他网站获取内容

时间:2015-08-02 12:57:26

标签: scala curl playframework

我认为可以使用播放框架从其他网站获取内容。

例如在php中,可以使用curl。

示例我有rute:

GET /test   controller.Aplicatin.getContent

当我放入浏览器localhost:9000 / test时,它显示来自示例http://google.pl的内容

可以将帖子数据发送到其他网站并获取内容吗?

例如,通过键入localhost:9000 / test我wana将用户名,密码发送到gmail并从登录页面返回内容。

1 个答案:

答案 0 :(得分:0)

您可以在控制器操作中执行任何操作。使用WS lib来制作你想要的任何类型的请求,然后以html或其他任何方式返回。

示例:

  def getContent = Action.async { implicit req =>
    WS.url("someurl.com").post("some body here").map(response => Ok(response.body))
  }