kopia lustrzana https://github.com/dgtlmoon/changedetection.io
Prefer pythons built in "importlib" over pkg_resources+setuptools (#2424)
rodzic
8ae5ed76ce
commit
cc147be76e
|
@ -255,8 +255,8 @@ class browsersteps_live_ui(steppable_browser_interface):
|
||||||
|
|
||||||
def get_current_state(self):
|
def get_current_state(self):
|
||||||
"""Return the screenshot and interactive elements mapping, generally always called after action_()"""
|
"""Return the screenshot and interactive elements mapping, generally always called after action_()"""
|
||||||
from pkg_resources import resource_string
|
import importlib.resources
|
||||||
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")
|
||||||
now = time.time()
|
now = time.time()
|
||||||
self.page.wait_for_timeout(1 * 1000)
|
self.page.wait_for_timeout(1 * 1000)
|
||||||
|
|
||||||
|
@ -287,11 +287,9 @@ class browsersteps_live_ui(steppable_browser_interface):
|
||||||
:param current_include_filters:
|
:param current_include_filters:
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
|
import importlib.resources
|
||||||
self.page.evaluate("var include_filters=''")
|
self.page.evaluate("var include_filters=''")
|
||||||
from pkg_resources import resource_string
|
xpath_element_js = importlib.resources.read_text("changedetectionio.content_fetchers.res", "xpath_element_scraper.js")
|
||||||
# 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')
|
|
||||||
from changedetectionio.content_fetchers import visualselector_xpath_selectors
|
from changedetectionio.content_fetchers import visualselector_xpath_selectors
|
||||||
xpath_element_js = xpath_element_js.replace('%ELEMENTS%', visualselector_xpath_selectors)
|
xpath_element_js = xpath_element_js.replace('%ELEMENTS%', visualselector_xpath_selectors)
|
||||||
xpath_data = self.page.evaluate("async () => {" + xpath_element_js + "}")
|
xpath_data = self.page.evaluate("async () => {" + xpath_element_js + "}")
|
||||||
|
|
|
@ -64,10 +64,9 @@ class Fetcher():
|
||||||
render_extract_delay = 0
|
render_extract_delay = 0
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
from pkg_resources import resource_string
|
import importlib.resources
|
||||||
# The code that scrapes elements and makes a list of elements/size/position to click on in the VisualSelector
|
self.xpath_element_js = importlib.resources.read_text("changedetectionio.content_fetchers.res", 'xpath_element_scraper.js')
|
||||||
self.xpath_element_js = resource_string(__name__, "res/xpath_element_scraper.js").decode('utf-8')
|
self.instock_data_js = importlib.resources.read_text("changedetectionio.content_fetchers.res", 'stock-not-in-stock.js')
|
||||||
self.instock_data_js = resource_string(__name__, "res/stock-not-in-stock.js").decode('utf-8')
|
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def get_error(self):
|
def get_error(self):
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
# resources for browser injection/scraping
|
Ładowanie…
Reference in New Issue