~ihabunek/harvey

0f961f4e4b468a6efafb55eb6251f2c3ec9c17ff — Ivan Habunek a month ago 60f9ebc
Fix svijet medija loader
1 files changed, 4 insertions(+), 3 deletions(-)

M lib/harvey/providers/svijet_medija.ex
M lib/harvey/providers/svijet_medija.ex => lib/harvey/providers/svijet_medija.ex +4 -3
@@ 55,17 55,18 @@ defmodule Harvey.Providers.SvijetMedija do

  defp parse_products(document) do
    document
    |> Floki.find(".node--type-product")
    |> Floki.find(".view-main-content .node--type-product")
    |> Enum.map(&parse_product/1)
  end

  defp parse_product(product) do
    [path] = Floki.attribute(product, "about")
    url = "https://www.svijet-medija.hr#{path}"
    [anchor] = Floki.find(product, ".product--teaser__content-title a")
    [url] = Floki.attribute(anchor, "href")

    [json] = Floki.find(product, "[data-product-data]") |> Floki.attribute("data-product-data")
    data = Jason.decode!(json)
    name = Map.fetch!(data, "name")

    price_str = Map.fetch!(data, "discount_price")
    old_price_str = Map.fetch!(data, "mpc")