Skip to content

Commit

Permalink
Merge branch 'master' into 2039-restock-use-itemprop
Browse files Browse the repository at this point in the history
  • Loading branch information
dgtlmoon committed Jun 18, 2024
2 parents 43ddfa5 + cc147be commit 7164f33
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 11 deletions.
10 changes: 4 additions & 6 deletions changedetectionio/blueprint/browser_steps/browser_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,8 @@ def has_expired(self):

def get_current_state(self):
"""Return the screenshot and interactive elements mapping, generally always called after action_()"""
from pkg_resources import resource_string
xpath_element_js = resource_string(__name__, "../../content_fetchers/res/xpath_element_scraper.js").decode('utf-8')
import importlib.resources
xpath_element_js = importlib.resources.read_text("changedetectionio.content_fetchers.res", "xpath_element_scraper.js")
now = time.time()
self.page.wait_for_timeout(1 * 1000)

Expand Down Expand Up @@ -287,11 +287,9 @@ def request_visualselector_data(self):
:param current_include_filters:
:return:
"""

import importlib.resources
self.page.evaluate("var include_filters=''")
from pkg_resources import resource_string
# The code that scrapes elements and makes a list of elements/size/position to click on in the VisualSelector
xpath_element_js = resource_string(__name__, "../../content_fetchers/res/xpath_element_scraper.js").decode('utf-8')
xpath_element_js = importlib.resources.read_text("changedetectionio.content_fetchers.res", "xpath_element_scraper.js")
from changedetectionio.content_fetchers import visualselector_xpath_selectors
xpath_element_js = xpath_element_js.replace('%ELEMENTS%', visualselector_xpath_selectors)
xpath_data = self.page.evaluate("async () => {" + xpath_element_js + "}")
Expand Down
7 changes: 3 additions & 4 deletions changedetectionio/content_fetchers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,9 @@ class Fetcher():
render_extract_delay = 0

def __init__(self):
from pkg_resources import resource_string
# The code that scrapes elements and makes a list of elements/size/position to click on in the VisualSelector
self.xpath_element_js = resource_string(__name__, "res/xpath_element_scraper.js").decode('utf-8')
self.instock_data_js = resource_string(__name__, "res/stock-not-in-stock.js").decode('utf-8')
import importlib.resources
self.xpath_element_js = importlib.resources.read_text("changedetectionio.content_fetchers.res", 'xpath_element_scraper.js')
self.instock_data_js = importlib.resources.read_text("changedetectionio.content_fetchers.res", 'stock-not-in-stock.js')

@abstractmethod
def get_error(self):
Expand Down
1 change: 1 addition & 0 deletions changedetectionio/content_fetchers/res/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# resources for browser injection/scraping
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ validators~=0.21
brotli~=1.0
requests[socks]

urllib3==1.26.18
urllib3==1.26.19
chardet>2.3.0

wtforms~=3.0
Expand Down

0 comments on commit 7164f33

Please sign in to comment.