1

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"

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!

I'm using this command

{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

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

Thanks in advance

4

1 に答える 1

3

autoredirectリクエストを実行するときは無効にする必要があります。

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).
于 2012-10-01T12:57:51.343 に答える