跟随Erlang的Url [英] Follow the end Url in Erlang

查看:149
本文介绍了跟随Erlang的Url的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用RSS中的Url来查找结束URL!
所以例如我有这个URLhttp://coder.io/~a27983554a,其结果将是http://ferd.ca/code-janitor-nobody-s-dream-每个人的工作 - 如何 - erlang-can-help.html

I'm trying to follow a Url which is in a RSS to find the end URL! so for example I have this URL "http://coder.io/~a27983554a" and the result of following this will be "http://ferd.ca/code-janitor-nobody-s-dream-everyone-s-job-and-how-erlang-can-help.html"

结束URL保存在第一个URL的标题中,但问题是我需要向该网址发送请求以获取包含最终结果的响应!

The end URL is saved in the header of the first URL, but the problem is I need to send a request to that URL to get response containing the end result for me!

我使用此命令


{ok,{{Version,200,ReasonPhrase},Headers,Body}} = httpc:request(http://coder.io/~a27983554a)

{ok, {{Version, 200, ReasonPhrase}, Headers, Body}} = httpc:request("http://coder.io/~a27983554a")

但这只是给我该文件的标题,但是包含我的结果的网站的回复

but this just give me the Headers of the file but the response from the site containing my result

请帮助我
我是Erlang的新人,如果您可以提供简单的代码行,例如

Please help me I'm new in Erlang and it will be perfect if you can provide simple line of code for example

提前谢谢

推荐答案

执行请求时,需要禁用 autoredirect p>

You need to disable autoredirect when performing the request:

Method = get,
Url = "http://coder.io/~a27983554a",
HTTPOptions = [{autoredirect, false}],
{ok, {{_Version, 302, _StatusMsg}, Headers, Body}} =
    httpc:request(Method, {Url, []}, HTTPOptions, []),
Location = proplists:get_value("location", Headers).

这篇关于跟随Erlang的Url的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆