公开页抓取改为 Chrome 136 自洽身份 + 每节点 SQLite 养罐,Trafilatura 走 curl_cffi;MCP/README/接手说明与 09-02 现网复测对齐,避免消费方继续抄过期的站点三分表。 Co-authored-by: Cursor <cursoragent@cursor.com>
46 lines
1 KiB
Go
46 lines
1 KiB
Go
package scheduler
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"onesvm.com/onesvm/browser-server/internal/contract"
|
|
"onesvm.com/onesvm/browser-server/internal/session"
|
|
)
|
|
|
|
func (c *Core) attachSession(ctx context.Context, job *contract.JobEnvelope, adapter, egress string) {
|
|
if c.jar == nil || job == nil || job.Read == nil {
|
|
return
|
|
}
|
|
job.Session = c.jar.Attach(ctx, adapter, egress, job.Read.URL)
|
|
}
|
|
|
|
func (c *Core) commitSession(ctx context.Context, job contract.JobEnvelope, raw *contract.RawResult, eb *contract.ErrBody) {
|
|
if c.jar == nil || job.Session == nil {
|
|
return
|
|
}
|
|
c.jar.Commit(ctx, job.Session, raw, eb)
|
|
}
|
|
|
|
func (c *Core) jarReaperLoop(ctx context.Context) {
|
|
defer c.wg.Done()
|
|
t := time.NewTicker(session.ReapEvery)
|
|
defer t.Stop()
|
|
for {
|
|
select {
|
|
case <-ctx.Done():
|
|
return
|
|
case <-c.stopCh:
|
|
return
|
|
case <-t.C:
|
|
n, err := c.jar.Reap(ctx)
|
|
if err != nil {
|
|
c.log.Printf("session reap 错误: %v", err)
|
|
continue
|
|
}
|
|
if n > 0 {
|
|
c.log.Printf("session reap 删除 %d 行", n)
|
|
}
|
|
}
|
|
}
|
|
}
|