import base64,json,requests
WP='https://tslaw.id/wp-json/wp/v2'
UA='Mozilla/5.0 (Windows NT 10.0; Win64; x64) Chrome/120 Safari/537.36'
AUTH='Basic '+base64.b64encode(b'bambangbot:EFKm EYGx VQCP Y9go ncPr uM2Y').decode()
GOOD='6281909222026'
BAD_CANDIDATES=['62819092220261935000624','62819350006241909222026','628190922202662819','6281935000624']

pid=3208
r=requests.get(f'{WP}/posts/{pid}',headers={'User-Agent':UA},timeout=60)
html=(r.json().get('content') or {}).get('rendered','')
print('--- BEFORE post 3208 ---')
for c in BAD_CANDIDATES:
    print(f'  {c}: x{html.count(c)}')
print('  clean 6281909222026:', html.count('6281909222026'))

new=html
for c in BAD_CANDIDATES:
    new=new.replace(c, GOOD)
# fallback: pola angka panjang >15 digit tanpa pemisah
import re
new=re.sub(r'6281909222026\d+', GOOD, new)
print('  after fix clean count:', new.count(GOOD))
up=requests.post(f'{WP}/posts/{pid}',
    headers={'Authorization':AUTH,'User-Agent':UA,'Content-Type':'application/json'},
    json={'content':new},timeout=90)
print('  update status:',up.status_code)
if up.status_code in (200,201):
    v=requests.get(f'{WP}/posts/{pid}',headers={'User-Agent':UA},timeout=60).json()
    vr=v.get('content',{}).get('rendered','')
    print('--- AFTER verify post 3208 ---')
    print('  clean 6281909222026:', vr.count('6281909222026'))
    for c in BAD_CANDIDATES:
        print(f'  {c}: x{vr.count(c)}')
else:
    print('  ERR:',up.text[:300])
