MCPcopy
hub / github.com/unclecode/crawl4ai / execute_hook

Method execute_hook

crawl4ai/crawler_strategy.py:165–175  ·  view source on GitHub ↗
(self, hook_type: str, *args)

Source from the content-addressed store, hash-verified

163 raise ValueError(f"Invalid hook type: {hook_type}")
164
165 def execute_hook(self, hook_type: str, *args):
166 hook = self.hooks.get(hook_type)
167 if hook:
168 result = hook(*args)
169 if result is not None:
170 if isinstance(result, webdriver.Chrome):
171 return result
172 else:
173 raise TypeError(f"Hook {hook_type} must return an instance of webdriver.Chrome or None.")
174 # If the hook returns None or there is no hook, return self.driver
175 return self.driver
176
177 def update_user_agent(self, user_agent: str):
178 self.options.add_argument(f"user-agent={user_agent}")

Callers 3

__init__Method · 0.95
update_user_agentMethod · 0.95
crawlMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected