@@ -520,8 +520,31 @@ async function tryFetchAndParse(
520520 browserRendered = true ;
521521 }
522522 } else if ( ! finalHtml && requiresBrowser && ! browserAllowed ) {
523+ // WeChat often serves usable article HTML to a MicroMessenger UA. Try this
524+ // before the slower remote-browser/proxy paths so public page loads do not
525+ // wait on a long-running Browser Use session.
526+ if ( targetUrl . includes ( "mp.weixin.qq.com" ) ) {
527+ const staticResult = await tryStaticFetch (
528+ targetUrl , env , host , format , selector , forceBrowser , noCache , engine ,
529+ fallbacks , browserRendered , paywallDetected , sourceContentType ,
530+ resolvedUrl , method , progress , abortSignal , browserAllowed ,
531+ ) ;
532+ if ( staticResult . earlyReturn ) {
533+ return staticResult . earlyReturn ;
534+ }
535+ finalHtml = staticResult . finalHtml ;
536+ method = staticResult . method ;
537+ resolvedUrl = staticResult . resolvedUrl ;
538+ browserRendered = staticResult . browserRendered ;
539+ paywallDetected = staticResult . paywallDetected ;
540+ sourceContentType = staticResult . sourceContentType ;
541+ if ( finalHtml ) {
542+ fallbacks . add ( "wechat_static_fallback" ) ;
543+ }
544+ }
545+
523546 // Anonymous 用户无 browser 权限 — 先走 Browser Use 远程浏览器,再降级住宅代理
524- if ( env . BROWSER_USE_API_KEY ) {
547+ if ( ! finalHtml && env . BROWSER_USE_API_KEY ) {
525548 throwIfAborted ( abortSignal ) ;
526549 await progress ( "fetch" , "Fetching via remote browser" ) ;
527550 const buHtml = await fetchViaBrowserUse ( targetUrl , env . BROWSER_USE_API_KEY , abortSignal ) ;
@@ -541,28 +564,6 @@ async function tryFetchAndParse(
541564 }
542565 }
543566
544- // WeChat often serves usable article HTML to a MicroMessenger UA. Use this
545- // as a low-cost fallback for anonymous users before failing the request.
546- if ( ! finalHtml && targetUrl . includes ( "mp.weixin.qq.com" ) ) {
547- const staticResult = await tryStaticFetch (
548- targetUrl , env , host , format , selector , forceBrowser , noCache , engine ,
549- fallbacks , browserRendered , paywallDetected , sourceContentType ,
550- resolvedUrl , method , progress , abortSignal , browserAllowed ,
551- ) ;
552- if ( staticResult . earlyReturn ) {
553- return staticResult . earlyReturn ;
554- }
555- finalHtml = staticResult . finalHtml ;
556- method = staticResult . method ;
557- resolvedUrl = staticResult . resolvedUrl ;
558- browserRendered = staticResult . browserRendered ;
559- paywallDetected = staticResult . paywallDetected ;
560- sourceContentType = staticResult . sourceContentType ;
561- if ( finalHtml ) {
562- fallbacks . add ( "wechat_static_fallback" ) ;
563- }
564- }
565-
566567 if ( ! finalHtml ) {
567568 throw new ConvertError (
568569 "Fetch Failed" ,
0 commit comments