DmitriDumas

DmitriDumas

Decode a part of a website

Hi everyone. I am very new to elixir but finding it amazing. Here is what I am trying to do. I am trying to decode a certain part of a website that contains aviation forecast (Called TAF). In my mix.exs I have added the tesla and poison deps. I am using the steps from this site (https://medium.com/the-wheel/writing-your-first-elixir-package-part-2-4bd689a8551a).

The aviation weather site is (https://metarreader.com/FACT). FACT is the code for Cape Town. If you inspect the code (I am using google), you will find: section class=“report” . That will show you the weather forecase.

What I have done (Working in iex) is:

  1. response = Tesla.get(“https://metarreader.com/FACT”) All OK so far
  2. response = response.body. All OK so far
  3. {:ok, result} = Poison.decode response . This is where I get the following error:

** (MatchError) no match of right hand side value: {:error, {:invalid, “<”, 0}}

The way I see it is that I am trying to decode the entire body and there are many HTML tags which I understand. What I am trying to do as mentioned, is just get that part of the site that shows the forecast.

Kind regards
Dmitri

Most Liked

kokolegorille

kokolegorille

Hello,

You need Floki or similar to parse html.

Poison is for json, and there is now Jason instead.

Happy Elixir learning :slight_smile:

Where Next?

Popular in Questions Top

Kurisu
For example for a current url like http://localhost:4000/cosmetic/products?_utf8=✓&amp;query=perfume&amp;page=2, I would like to get: ...
New
qwerescape
Is there a way to get the call stack or stack trace at any point in the code? Not from exceptions, but an expression that returns how the...
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
JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
vac
Hi, I’m quite new in Elixir and I’m trying to format a string to a PEM format. I have the certificate value like MIIDBTCCAe2...... and I...
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
beno
I will often find my self writing things similar to: case some_value do nil -&gt; something() "" -&gt; something() _ -&gt; somethi...
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
lucidguppy
I have a super simple question about elixir - how would I take a file like this foo bar baz and output a new file that enumerates th...
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

Other popular topics Top

malloryerik
Hi, this is for people who, like me, have had some friction using .html.heex templates in VSCode. The solution seems to be, in a hyphena...
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
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
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set? Thanks.
New
Lily
In templates/appointment/index.html.eex: &lt;%= for appointment &lt;- @appointments do %&gt; &lt;tr&gt; &lt;td&gt;&lt;%= appoi...
New
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
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
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
jason.o
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New
PeterCarter
There are pre-rolled solutions for other frameworks that do work. However, Phoenix does not seem to have these. Have people had good expe...
New

We're in Beta

About us Mission Statement