def crawl(self, url: str) -> None:
"""
Crawls a given URL, extracts links, and adds them to the crawl results.
Args:
url (str): The URL to crawl.
"""
if not is_valid_url(url):
logger.debug("Invalid url to crawl: %s", url)
return
if url in self.crawl_result:
logger.debug("URL already crawled: %s", url)
return
if self.respect_robots_txt:
user_agent = requests.utils.default_user_agent()
robots_url = get_robots_txt_url(url)
# Use previously created RobotFileParser
if robots_url in self.robots:
robot_parser = self.robots[robots_url]
else:
robot_parser = setup_robots_txt_parser(robots_url)
self.robots[robots_url] = robot_parser
if not is_robots_txt_allowed(url, robot_parser):
logger.debug("Skipped: Url doesn't allow crawling: %s", url)
return
crawl_delay = float(robot_parser.crawl_delay(user_agent))
if crawl_delay is not None:
time.sleep(crawl_delay)
This piece of code is causing pylint to raise too-many-branches
What can I do to fix it?