drakvuf

drakvuf

Empty response

I’d like to scrape a website but for some reason, HTTPoison gives me an empty body.

iex> HTTPoison.get(“Origo”)
{:ok,
%HTTPoison.Response{
body: “”,
headers: [
{“Content-length”, “0”},
{“Location”, “Origo”}
],
request: %HTTPoison.Request{
body: “”,
headers: ,
method: :get,
options: ,
params: %{},
url: “Origo
},
request_url: “Origo”,
status_code: 301
}}

I tried it with HTTPotion too, the same result:
%HTTPotion.Response{
body: “”,
headers: %HTTPotion.Headers{
hdrs: %{
“content-length” => “0”,
“location” => “Origo
}
},
status_code: 301
}

I checked the site, it is definitely not empty. I tried to fetch it with Nodejs and it works with that.

As far as I understand both of these clients use Hackney and there is an issue about this on the HTTPoisonGithub. But this issue is closed, so I guess this problem shouldn’t exist anymore?
Does anyone have any idea what should I do here?

Marked As Solved

hubertlepicki

hubertlepicki

So you are getting a 301 redirect, precisely you are being redirected from http:// to https://.

You can use just http:// in the original URL, or configure HTTPoison to follow redirects like this: httpoison/test/httpoison_test.exs at 3481d567adcb06d129dfec3c69aa87d1719f7a8b · edgurgel/httpoison · GitHub

Also Liked

hubertlepicki

hubertlepicki

That happens a lot, sometimes you just end up writing question or explain problem to someone and solution comes in, sometimes you actually need 2nd pair of eyes to spot obvious.

drakvuf

drakvuf

OMG. Feel so stupid right now. Thank you so much! I don’t know how I missed the status code…

Where Next?

Popular in Questions Top

skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
chrisalley
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New
shahryarjb
Hello, I get Persian date from my client and convert it to normal calendar like this: def jalali_string_to_miladi_english_number(persi...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
jaysoifer
Is there a way to rollback a specific migration and only that one (“skipping” all the other ones)? Would mix ecto.rollback -v 200809061...
New

Other popular topics Top

axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 48475 226
New
New
AstonJ
We’ve put together this wiki for Phoenix LiveView - please feel free to add any info you feel is worth including. What is Phoenix LiveV...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 36432 110
New
Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
sergio
Kind of like when jquery came out, it was super necessary. Existing drag and drop libraries have a bunch of baggage to support old browse...
New

We're in Beta

About us Mission Statement