From 774ace6e3b157a119e0d1169c505f7e985b4ca57 Mon Sep 17 00:00:00 2001 From: unclecode Date: Sun, 2 Jun 2024 18:00:53 +0800 Subject: [PATCH] Update html page for tutorial. --- pages/partial/how_to_guide.html | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pages/partial/how_to_guide.html b/pages/partial/how_to_guide.html index b8f85ed6..3ad53ce4 100644 --- a/pages/partial/how_to_guide.html +++ b/pages/partial/how_to_guide.html @@ -139,13 +139,14 @@ crawler.warmup()
Using JavaScript to click 'Load More' button:
-
js_code = """
+            
js_code = ["""
 const loadMoreButton = Array.from(document.querySelectorAll('button')).find(button => button.textContent.includes('Load More'));
 loadMoreButton && loadMoreButton.click();
-"""
+"""]
 crawler_strategy = LocalSeleniumCrawlerStrategy(js_code=js_code)
 crawler = WebCrawler(crawler_strategy=crawler_strategy, always_by_pass_cache=True)
 result = crawler.run(url="https://www.nbcnews.com/business")
+
Remember that you can pass multiple JavaScript code snippets in the list. They all will be executed in the order they are passed.