A Smart, Automatic, Fast and Lightweight Web Scraper for Python
Python aiartificial-intelligenceautomationcrawlermachine-learningpythonscrapescraperscrapingweb-scrapingwebautomationwebscraping
refactor: remove unneeded .rstrip()s after .strip()
cthulhu-irl9e1555f3d97e
diff --git a/autoscraper/auto_scraper.py b/autoscraper/auto_scraper.pyindex 31252cd..cd277d3 100644--- a/autoscraper/auto_scraper.py+++ b/autoscraper/auto_scraper.py@@ -53,7 +53,7 @@ class AutoScraper(object):return attrsdef _child_has_text(self, child, text):- child_text = child.getText().strip().rstrip()+ child_text = child.getText().strip()if text == child_text:child.wanted_attr = Nonereturn True@@ -62,7 +62,7 @@ class AutoScraper(object):if not isinstance(value, str):continue- value = value.strip().rstrip()+ value = value.strip()if text == value:child.wanted_attr = keyreturn True@@ -77,7 +77,7 @@ class AutoScraper(object):return Falsedef _get_children(self, soup, text):- text = text.strip().rstrip()+ text = text.strip()children = reversed(soup.findChildren())children = list(filter(lambda x: self._child_has_text(x, text), children))@@ -160,7 +160,7 @@ class AutoScraper(object):def _fetch_result_from_child(self, child, wanted_attr, is_full_url):if wanted_attr is None:- return child.getText().strip().rstrip()+ return child.getText().strip()if wanted_attr not in child.attrs:return Nonediff --git a/autoscraper/code_template.py b/autoscraper/code_template.pyindex 7bcda11..afa1968 100644--- a/autoscraper/code_template.py+++ b/autoscraper/code_template.py@@ -40,7 +40,7 @@ class GeneratedAutoScraper(object):def _fetch_result_from_child(self, child, wanted_attr, is_full_url):if wanted_attr is None:- return child.getText().strip().rstrip()+ return child.getText().strip()if wanted_attr not in child.attrs:return None