Skip to content

Commit

Permalink
update scraped_page references when it's refreshed (#1151)
Browse files Browse the repository at this point in the history
  • Loading branch information
wintonzheng authored Nov 7, 2024
1 parent 5583dee commit c531f9b
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion skyvern/webeye/scraper/scraper.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,13 +242,25 @@ def build_element_tree(self, fmt: ElementTreeFormat = ElementTreeFormat.JSON) ->
raise UnknownElementTreeFormat(fmt=fmt)

async def refresh(self, with_screenshot: bool = True) -> Self:
return await scrape_website(
refreshed_page = await scrape_website(
browser_state=self._browser_state,
url=self.url,
cleanup_element_tree=self._clean_up_func,
scrape_exclude=self._scrape_exclude,
with_screenshot=with_screenshot,
)
self.elements = refreshed_page.elements
self.id_to_css_dict = refreshed_page.id_to_css_dict
self.id_to_element_dict = refreshed_page.id_to_element_dict
self.id_to_frame_dict = refreshed_page.id_to_frame_dict
self.id_to_element_hash = refreshed_page.id_to_element_hash
self.hash_to_element_ids = refreshed_page.hash_to_element_ids
self.element_tree = refreshed_page.element_tree
self.element_tree_trimmed = refreshed_page.element_tree_trimmed
self.screenshots = refreshed_page.screenshots or self.screenshots
self.html = refreshed_page.html
self.extracted_text = refreshed_page.extracted_text
return self


async def scrape_website(
Expand Down

0 comments on commit c531f9b

Please sign in to comment.