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

Restock & Price monitor - Use itemprop where available #2041

Merged
merged 95 commits into from
Jul 12, 2024
Merged
Changes from 2 commits
Commits
Show all changes
95 commits
Select commit Hold shift + click to select a range
436c412
Re #2039 - Use itemprop where available
dgtlmoon Dec 8, 2023
d58c24d
Set false text also
dgtlmoon Dec 8, 2023
a16b129
Simplify logic
dgtlmoon Dec 9, 2023
0f9d3a0
logic fixes and force faster xpath1
dgtlmoon Dec 9, 2023
8090d0d
cleanup
dgtlmoon Dec 9, 2023
69513c4
Offer more helpful text
dgtlmoon Dec 9, 2023
61185b5
Tidy imports
dgtlmoon Dec 9, 2023
b71b457
Merge branch 'master' into 2039-restock-use-itemprop
dgtlmoon Jan 14, 2024
37d081c
Merge branch 'master' into 2039-restock-use-itemprop
dgtlmoon May 3, 2024
49246bc
Merge branch '2039-restock-use-itemprop' of github.com:dgtlmoon/chang…
dgtlmoon May 3, 2024
86f1d8b
Make it testable
dgtlmoon May 3, 2024
fe8b7b8
Adding test
dgtlmoon May 3, 2024
2aa8ca0
tweaks
dgtlmoon May 3, 2024
345b54d
add more test examples
dgtlmoon May 3, 2024
0b85990
more work
dgtlmoon May 6, 2024
b1170c1
WIP
dgtlmoon May 7, 2024
41a6c60
test note needed
dgtlmoon May 7, 2024
8680a29
UI tweaks
dgtlmoon May 7, 2024
ceeb4d5
tweak styles
dgtlmoon May 7, 2024
32e074d
Merge branch 'master' into 2039-restock-use-itemprop
dgtlmoon May 7, 2024
d38bb61
big refactor
dgtlmoon May 10, 2024
9ffa4ed
UI - Search should scan/search error messages
dgtlmoon May 10, 2024
17c87f4
Merge branch 'ui-search-error-messages' into 2039-restock-use-itemprop
dgtlmoon May 10, 2024
df6d120
Merge branch 'master' into 2039-restock-use-itemprop
dgtlmoon May 22, 2024
9290445
tweak imports
dgtlmoon May 22, 2024
d1528bb
Misc tweaks
dgtlmoon May 22, 2024
c1a0481
skip rdfa?
dgtlmoon May 23, 2024
d0acc59
Merge branch 'master' into 2039-restock-use-itemprop
dgtlmoon Jun 4, 2024
fa62096
Merge branch 'master' into 2039-restock-use-itemprop
dgtlmoon Jun 4, 2024
f5dba66
small fix
dgtlmoon Jun 4, 2024
6024d02
Merge branch 'master' into 2039-restock-use-itemprop
dgtlmoon Jun 5, 2024
f983ec2
Merge branch 'master' into 2039-restock-use-itemprop
dgtlmoon Jun 7, 2024
e1c903b
part 1/2 - Abstract out form handling for the form class
dgtlmoon Jun 11, 2024
18f80e1
abstract out the extra tab
dgtlmoon Jun 12, 2024
ded4495
Adding follow_price_changes
dgtlmoon Jun 12, 2024
cf43852
Fixing test setup
dgtlmoon Jun 12, 2024
e756002
min/mnax price check
dgtlmoon Jun 12, 2024
99f7f78
fix test
dgtlmoon Jun 12, 2024
b9b0a92
fix
dgtlmoon Jun 12, 2024
37a021a
fix styling
dgtlmoon Jun 12, 2024
32579d7
fix debug message
dgtlmoon Jun 12, 2024
575bdcf
WIP
dgtlmoon Jun 12, 2024
b39c770
adding % threshold handling
dgtlmoon Jun 12, 2024
afc88d6
Merge branch 'master' into 2039-restock-use-itemprop
dgtlmoon Jun 13, 2024
6824fa2
workaround for no previous price present
dgtlmoon Jun 13, 2024
dcd000e
add check delays
dgtlmoon Jun 14, 2024
7aa1e5c
Merge branch 'master' into 2039-restock-use-itemprop
dgtlmoon Jun 17, 2024
8915171
not used
dgtlmoon Jun 17, 2024
a59a674
Merge branch 'master' into 2039-restock-use-itemprop
dgtlmoon Jun 17, 2024
9b8b760
add delay for GH
dgtlmoon Jun 17, 2024
d135240
store everything
dgtlmoon Jun 17, 2024
f9f83e6
hmm
dgtlmoon Jun 17, 2024
4ba847e
hmm
dgtlmoon Jun 17, 2024
43ddfa5
Add delay
dgtlmoon Jun 17, 2024
7164f33
Merge branch 'master' into 2039-restock-use-itemprop
dgtlmoon Jun 18, 2024
a46d45e
difference should be since first check
dgtlmoon Jun 18, 2024
34ab79e
Placehodler text
dgtlmoon Jun 18, 2024
9dd0434
WIP
dgtlmoon Jun 18, 2024
c32173b
Merge branch 'master' into 2039-restock-use-itemprop
dgtlmoon Jul 9, 2024
90a286a
Update restock_diff.py
dgtlmoon Jul 9, 2024
85aa23d
Merge branch 'master' into 2039-restock-use-itemprop
dgtlmoon Jul 9, 2024
6a96adb
Merge branch 'master' into 2039-restock-use-itemprop
dgtlmoon Jul 9, 2024
5765d12
Fixing deprecation warning
dgtlmoon Jul 9, 2024
a1d9a82
Merge branch 'fix-legacy-file-import' into 2039-restock-use-itemprop
dgtlmoon Jul 9, 2024
5f3ec26
Adding object sanity test
dgtlmoon Jul 9, 2024
9629b89
Fixing data problem
dgtlmoon Jul 9, 2024
b05c7ae
Make the option to select a processor easier to understand/find
dgtlmoon Jul 9, 2024
7f5bdd4
Make processors more cleanly separated
dgtlmoon Jul 10, 2024
c497192
Woops
dgtlmoon Jul 10, 2024
ed0ffd6
few tweaks
dgtlmoon Jul 10, 2024
13a714b
small tweaks
dgtlmoon Jul 10, 2024
e5edb91
couple small fixes
dgtlmoon Jul 10, 2024
a9346a6
make the templates dir more reliable
dgtlmoon Jul 10, 2024
11815b6
add a little extra debug
dgtlmoon Jul 10, 2024
248161b
Migrate earlier 'in stock' values
dgtlmoon Jul 11, 2024
025946c
Merge branch 'master' into 2039-restock-use-itemprop
dgtlmoon Jul 11, 2024
52eb560
Merge branch 'master' into 2039-restock-use-itemprop
dgtlmoon Jul 11, 2024
685624c
Properly format the amount
dgtlmoon Jul 11, 2024
44d07ce
Handle when microdata/embvdeed stock not foudn but we can scrape it
dgtlmoon Jul 11, 2024
8fe5a3d
Adding locale debug and packages
dgtlmoon Jul 11, 2024
08a96cd
Add try/except
dgtlmoon Jul 11, 2024
797109d
woops
dgtlmoon Jul 11, 2024
60040a9
Change of processor should reset the datastore for that watch
dgtlmoon Jul 12, 2024
9da549c
Just a basic string watch is far more efficient for suggestion price/…
dgtlmoon Jul 12, 2024
a855b3d
import fix
dgtlmoon Jul 12, 2024
3da6e74
Handle multiple products error
dgtlmoon Jul 12, 2024
97345ab
Merge branch 'master' into 2039-restock-use-itemprop
dgtlmoon Jul 12, 2024
682ae1a
Small fix for missing var
dgtlmoon Jul 12, 2024
51daba1
fixing testsd
dgtlmoon Jul 12, 2024
427860f
Fixing exceptions and multiple price finding
dgtlmoon Jul 12, 2024
2121b90
Merge branch 'master' into 2039-restock-use-itemprop
dgtlmoon Jul 12, 2024
fbfacd5
fix abd merge
dgtlmoon Jul 12, 2024
50f00a2
tidy up tests, fix price detection
dgtlmoon Jul 12, 2024
20ec3cd
test either locales
dgtlmoon Jul 12, 2024
930c551
add some small delay
dgtlmoon Jul 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions changedetectionio/processors/restock_diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,23 @@ class perform_site_check(difference_detection_processor):
screenshot = None
xpath_data = None

def get_itemprop_availability(self):
from ..html_tools import xpath_filter
import re
# <link itemprop="availability" href="https://schema.org/OutOfStock" />
# https://schema.org/ItemAvailability
value = None
try:
value = xpath_filter("//link[@itemprop='availability']/@href", self.fetcher.content)
if value:
value = re.sub(r'(?i)^http(s)+://schema.org/', '', value.strip())

except Exception as e:
print("Exception getting get_itemprop_availability", str(e))

return value


def run_changedetection(self, uuid, skip_when_checksum_same=True):

# DeepCopy so we can be sure we don't accidently change anything by reference
Expand All @@ -39,6 +56,24 @@ def run_changedetection(self, uuid, skip_when_checksum_same=True):

# Main detection method
fetched_md5 = None

# Try/prefer the structured data first if it exists
# https://schema.org/ItemAvailability Which strings mean we should consider it in stock?
availability = self.get_itemprop_availability()
if availability:
if any(availability in s for s in
[
'InStock',
'InStoreOnly',
'LimitedAvailability',
'OnlineOnly',
'PreSale' # Debatable?
]):
self.fetcher.instock_data = 'Possibly in stock'
else:
self.fetcher.instock_data = availability
dgtlmoon marked this conversation as resolved.
Show resolved Hide resolved

# Fallback to scraping the content for keywords (done in JS)
if self.fetcher.instock_data:
fetched_md5 = hashlib.md5(self.fetcher.instock_data.encode('utf-8')).hexdigest()
# 'Possibly in stock' comes from stock-not-in-stock.js when no string found above the fold.
Expand Down