31 lines
1.2 KiB
Python
31 lines
1.2 KiB
Python
import re
|
|
import urllib.request
|
|
|
|
req = urllib.request.Request('https://www.zhuig.com/community', headers={'User-Agent': 'Mozilla/5.0', 'Cache-Control': 'no-cache'})
|
|
html = urllib.request.urlopen(req, timeout=15).read().decode('utf-8')
|
|
|
|
# 找所有 script 标签里的self.__next_f.push
|
|
scripts = re.findall(r'<script[^>]*>(self\.__next_f\.push.*?)</script>', html, re.DOTALL)
|
|
print(f'RSC push script 块数: {len(scripts)}')
|
|
|
|
for i, s in enumerate(scripts):
|
|
# 第一个字符切片, 找$12声明
|
|
if '"$12"' in s or '"$L12"' in s or '$12' in s:
|
|
# 找"$12":开头的声明
|
|
m = re.search(r'"\$?L?12":\s*"([^"]{0,500})', s)
|
|
if m:
|
|
print(f'\n=== Script {i} 含 $12 引用 (前500字符) ===')
|
|
print(m.group(1)[:500])
|
|
# 也找"children":"$12"
|
|
m2 = re.search(r'__html":\s*"(\$12|\$L12)"', s)
|
|
if m2:
|
|
print(f' Script {i} 在 __html 用 $12')
|
|
|
|
# 找所有包含"平台电商"的script
|
|
for i, s in enumerate(scripts):
|
|
if '平台电商' in s or '电商零售' in s:
|
|
idx = s.find('平台电商')
|
|
if idx == -1: idx = s.find('电商零售')
|
|
print(f'\n=== Script {i} 含"电商零售/平台电商" 位置{idx} ===')
|
|
print(s[max(0,idx-30):idx+300])
|