@@ 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")