Skip to content
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

Amazon Price Tracker Bridge #741

Merged
merged 2 commits into from
Jul 16, 2018

Conversation

captn3m0
Copy link
Contributor

@captn3m0 captn3m0 commented Jul 8, 2018

I'm not entirely sure of how the caching works with RSS-Bridge. I've left the cache timeout to 1h, would it start showing up with duplicate feed entries for every 1hour? (I'm hoping not). Another possible issue might be the URL not changing (and feed readers not caring about the new content).

As a hack I was considering, appending the $item['url'] with a clear query param of price:

https://www.amazon.in/dp/B00WTHJ5SU/#price=$price

That way, it would definitely get picked up as a new feed item on any feed reader.

@captn3m0
Copy link
Contributor Author

captn3m0 commented Jul 9, 2018

Looks decent:
image

Would be nice if folks can test this with some other TLDs (I'm primarily testing on Amazon India)

@captn3m0 captn3m0 force-pushed the amazon-price-tracker branch 2 times, most recently from afc9975 to 228c64d Compare July 9, 2018 10:13
Copy link
Contributor

@logmanoriginal logmanoriginal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very interesting bridge 👍

I've been using different services up till now, but this looks promising.

Please find below a few comments. I don't think the typo fix is a problem here.

Is there any reason to keep this separated from the existing Amazon bridge?

],
'defaultValue' => 'com',
],
]];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use array() instead of []

Your solution is neither wrong nor incorrect, just different than all other bridges.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just force of habit. Will change here, but thoughts about shifting to short array notation everywhere? It is far more readable (I did that in #719, but that wasn't well thought out).

The lowest we support is 5.6 (5.4 with the conversion script), short array is there since 5.4


public function getName(){
if(!is_null($this->getInput('tld')) && !is_null($this->getInput('q'))) {
return 'Amazon.'.$this->getInput('tld').': '.$this->getInput('q');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be spaces around ' . ' like the rest

[
'asin' => [
'name' => 'ASIN',
'required' => true,
Copy link
Contributor

@logmanoriginal logmanoriginal Jul 9, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any chance catching invalid user input using pattern matching?

Maybe add an example value?

'exampleValue' => 'B071GB1VMQ'

or returnServerError('Could not request Amazon.');

// <img class="... frontImage" data-a-dynamic-image="{&quot;<image_url>&quot;:[$width,$height]}">
$imageHtml = $html->find('.frontImage')[0]->getAttribute('data-a-dynamic-image');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why, but my HTML looks very different from what you expect. There is no .frontImage in my source, so this line fails on me, using this query: ?action=display&bridge=AmazonPriceTracker&asin=B071GB1VMQ&tld=com&format=Html

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Went through the html and found an interesting element that we can use:

<div id="cerberus-data-metrics" style="display: none;" data-asin="B00WTHJ5SU" data-asin-price="14.99" data-asin-shipping="0" data-asin-currency-code="USD" data-substitute-count="-1" ...>

'title' => $title,
'uri' => $uri,
'content' => "<img alt='$title' src='$imageSrc'/><br/>$price $currency",
];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above, please opt for the long array notation

@captn3m0 captn3m0 force-pushed the amazon-price-tracker branch from 228c64d to f40ab0a Compare July 9, 2018 21:48
@captn3m0
Copy link
Contributor Author

captn3m0 commented Jul 9, 2018

General comments:

Is there any reason to keep this separated from the existing Amazon bridge?

They serve distinct purpose: First is to notify you about new products that match your search criteria. The second is to notify you about price changes in a specific product. I'd want to add features like: "Minimum price" or "minimum discount" to this bridge, but they don't make much sense in the other one.

Very interesting bridge 👍

Thanks! I was using external services for this as well, but they keep shutting down. The best alternative I found was https://github.com/GaryniL/Amazon-Price-Alert, but it requires too much setup and (most importantly) doesn't do RSS.

I'm planning to add a "Amazon Wishlist" adapter in https://git.captnemo.in/nemo/opml-gen, so that I can generate a bunch of RSS feeds for my entire Wishlist and import it in my feed reader at once.

@captn3m0 captn3m0 force-pushed the amazon-price-tracker branch 2 times, most recently from b3848dc to 1acaed2 Compare July 9, 2018 22:37
@captn3m0 captn3m0 force-pushed the amazon-price-tracker branch from 1acaed2 to 24a07a2 Compare July 9, 2018 22:54
Copy link
Member

@teromene teromene left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few function names that don't really make sense

/**
* Generates domain name given a amazon TLD
*/
private function makeDomainName() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably be named getDomainName

/**
* Generates URI for a Amazon product page
*/
private function makeUri() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

* Scrapes the product title from the html page
* returns the default title if scraping fails
*/
private function extractTitle($html) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

@captn3m0 captn3m0 force-pushed the amazon-price-tracker branch 2 times, most recently from ffc6304 to 1397166 Compare July 10, 2018 01:07
@captn3m0 captn3m0 force-pushed the amazon-price-tracker branch from 1397166 to 0d5927a Compare July 10, 2018 06:15
@teromene teromene dismissed logmanoriginal’s stale review July 16, 2018 12:54

Author updated the PR

@teromene teromene merged commit c7b0c9f into RSS-Bridge:master Jul 16, 2018
@teromene
Copy link
Member

Merged, thanks !

@captn3m0 captn3m0 deleted the amazon-price-tracker branch July 16, 2018 12:57
infominer33 pushed a commit to web-work-tools/rss-bridge that referenced this pull request Apr 17, 2020
* [amazonprice] Adds AmazonPriceTracker bridge
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants