【问题标题】:Play Framework - Get content from other sitePlay Framework - 从其他站点获取内容
【发布时间】:2015-08-02 12:57:25
【问题描述】:

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

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

例如我有 rute :

GET /test   controller.Aplicatin.getContent

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

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

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

【问题讨论】:

    标签: scala curl playframework


    【解决方案1】:

    您可以在控制器操作中做任何您想做的事情。使用 WS 库发出您想要的任何类型的请求,然后以 html 或其他格式返回。

    例子:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-09-21
      • 1970-01-01
      • 2019-05-13
      • 2012-05-01
      • 2014-04-16
      • 2015-10-22
      • 2013-08-14
      相关资源
      最近更新 更多