@@ -13,7 +13,6 @@ const puppeteer = require('puppeteer');
13
13
await page . waitForSelector ( '#__docusaurus > nav > div.navbar__inner > div.navbar__items.navbar__items--right > div.navbarSearchContainer_IP3a > button > span.DocSearch-Button-Container > svg' ) ;
14
14
await page . click ( '#__docusaurus > nav > div.navbar__inner > div.navbar__items.navbar__items--right > div.navbarSearchContainer_IP3a > button > span.DocSearch-Button-Container > svg' ) ;
15
15
// Type into search box
16
- // await page.type('.navbarSearchContainer_IP3a input', 'chipi chipi chapa chapa');
17
16
await page . waitForSelector ( '.DocSearch-Input' ) ;
18
17
await page . type ( '.DocSearch-Input' , 'andy popoo' , { delay : 100 } ) ;
19
18
@@ -26,24 +25,11 @@ const puppeteer = require('puppeteer');
26
25
const docsSection = await page . $$ ( '.DocSearch-Hit' ) ;
27
26
const limit = 5 ; // limit the number of results to show
28
27
const visibleDocsSection = docsSection . slice ( 0 , limit ) ; // get the first 5 results
29
- // if (visibleDocsSection.length > 0) {
30
- // for (let i = 0; i < visibleDocsSection.length; i++) {
31
- // const title = await visibleDocsSection[i].$eval('.DocSearch-Hit-title', el => el.innerText);
32
- // // console.log(`搜尋結果 ${i + 1}: ${title}`);
33
- // }
34
-
35
- // // Click the first result
36
- // const clickedTitle = await visibleDocsSection[0].$eval('.DocSearch-Hit-title', el => el.innerText);
37
- // // console.log(`即將點擊的搜尋結果: ${clickedTitle}`);
38
-
39
- // await visibleDocsSection[4].click();
40
- // } else {
41
- // console.log('Results not found!');
42
- // }
28
+
43
29
if ( visibleDocsSection . length > 0 ) {
44
- await visibleDocsSection [ 4 ] . click ( ) ; // 點擊第一個搜尋結果
30
+ await visibleDocsSection [ 4 ] . click ( ) ;
45
31
} else {
46
- console . log ( '搜尋結果沒有找到! ' ) ;
32
+ console . log ( 'No results found ' ) ;
47
33
}
48
34
// Locate the title
49
35
// Print the title
0 commit comments