Skip to content

Commit

Permalink
chromedp
Browse files Browse the repository at this point in the history
  • Loading branch information
kaki-admin committed Nov 15, 2024
1 parent cfc1e2e commit ef2fea4
Showing 1 changed file with 1 addition and 21 deletions.
22 changes: 1 addition & 21 deletions backend-server/crawler/entry.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
package crawler

import (
"bytes"
"context"
"fmt"
"io"
"net/url"
"os"
"strings"
"sync"
"time"

"bytetrade.io/web3os/backend-server/common"
Expand Down Expand Up @@ -116,25 +113,8 @@ func notionFetchByheadless(websiteURL string) string {
//chromedp.Flag("accept-language", `zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7,zh-TW;q=0.6`),
)

var bufMu sync.Mutex
var buf bytes.Buffer
fn := func(format string, a ...interface{}) {
bufMu.Lock()
fmt.Fprintf(&buf, format, a...)
fmt.Fprintln(&buf)
bufMu.Unlock()
}

ctx, cancel := chromedp.NewContext(
context.Background(),
chromedp.WithErrorf(fn),
chromedp.WithLogf(fn),
chromedp.WithDebugf(fn),
)
defer cancel()

headlessSer := os.Getenv("HEADLESS_SERVER_URL")
ctx, cancel = context.WithTimeout(ctx, 90*time.Second)
ctx, cancel := context.WithTimeout(context.Background(), 90*time.Second)
defer cancel()

if headlessSer != "" {
Expand Down

0 comments on commit ef2fea4

Please sign in to comment.