-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added in chicago elec dist #50
added in chicago elec dist #50
Conversation
id: "chicagoelecdistus", | ||
name: "Chicago Elec. Dist.", | ||
country: :us, | ||
homepage: "https://chicagodist.com/" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you remove the trailing /
. (Damn this OCD all the time :D)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, sorry!
The parsing looks good. Two things:
Product that is on stock which has an items count: https://chicagodist.com/products/12-vdc-1000ma-regulated-switching-power-adapter-ul-listed |
|
sku: "RPI4-MODBP-2GB" | ||
}, | ||
%ProductUpdate{ | ||
url: "https://chicagodist.com/collections/raspberry-pi/products/raspberry-pi-4-model-b-1gb", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets change the url to https://chicagodist.com/products/raspberry-pi-4-model-b-1gb
to be consistent with the other urls.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed! I put them in order too (to help with the OCD ha)
Floki.find(html_tree, ".product_form") | ||
|> Floki.attribute("data-variant-inventory") | ||
|> Enum.at(0) | ||
|> Jason.decode() | ||
|
||
get_in(elem(json_product_data, 1) |> Enum.at(0), ["inventory_quantity"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can change the code to this to reuse the existing variable and also simplify the last line where you get the value out of the json.
available_quantity
|> Enum.at(0)
|> Jason.decode!()
Enum.at(json_product_data, 0)["inventory_quantity"]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done!
Looks good to me! Thanks! |
Added in Chicago Elec. Dist.