-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor: facade pattern for scrape helper
- Loading branch information
1 parent
9d56f7e
commit 6cc7c91
Showing
5 changed files
with
47 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from selectolax.parser import Node | ||
|
||
|
||
class ScrapeHelper: | ||
@staticmethod | ||
def get_text(node: Node, selector: str) -> str | None: | ||
element = node.css_first(selector) | ||
return element.text().strip() if element else None | ||
|
||
@staticmethod | ||
def get_attribute(node: Node, selector: str, attribute: str) -> str | None: | ||
element = node.css_first(selector) | ||
return element.attributes[attribute] if element else None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.