import requests, urllib3, json
urllib3.disable_warnings()
BASE = "https://www.fansky.net"
paths = [l.strip() for l in open('endpoints.txt') if l.strip()]
s = requests.Session()
s.headers.update({'User-Agent':'Mozilla/5.0','Accept':'application/json','Content-Type':'application/json'})
s.verify = False
out=[]
for p in paths:
    url = BASE + p
    try:
        r = s.post(url, data='{}', timeout=20, allow_redirects=False)
        body = r.text[:250].replace('\n',' ')
        out.append((r.status_code, len(r.content), p, body))
    except Exception as e:
        out.append(('ERR',0,p,str(e)[:100]))
print("=== NON 401/404/405 responses (POST empty {}) ===")
for code,size,p,body in out:
    if code not in (401,404,405):
        print(f"{code}\t{size}\t{p}\t{body[:180]}")
print()
from collections import Counter
print(dict(Counter(str(x[0]) for x in out)))
with open('sweep_post.json','w') as f:
    json.dump([{'code':x[0],'size':x[1],'path':x[2],'body':x[3]} for x in out], f, indent=1)
