import urllib.request import urllib.parse import http.cookiejar cj = http.cookiejar.CookieJar() opener = urllib.request.build_opener(urllib.request.HTTPCookieProcessor(cj)) # 1. 尝试登录 login_url = "http://127.0.0.1:9560/s.php/index/login" login_data = urllib.parse.urlencode({'username': 'admin', 'password': 'asdasd11'}).encode('utf-8') req = urllib.request.Request(login_url, data=login_data, headers={'Host': 'yjyf:9560', 'X-Requested-With': 'XMLHttpRequest'}) try: resp = opener.open(req, timeout=5) print("Login response:", resp.read().decode('utf-8', errors='ignore')) except Exception as e: print("Login err:", e) # 2. 读取 service 页面 try: req2 = urllib.request.Request("http://127.0.0.1:9560/s.php/service", headers={'Host': 'yjyf:9560'}) resp2 = opener.open(req2, timeout=5) content = resp2.read().decode('utf-8', errors='ignore') print("Service page fetched successfully! Length:", len(content)) # 验证页面中是否去除了 price_type 胶囊,并保留了专业业务胶囊 if "一口价模式" in content or "师傅报价模式" in content: print("Warning: Found legacy price_type string in template!") else: print("Success: Verified that price_type is fully removed from index.html template!") if "srv-filter-container" in content: print("Success: Verified modern SaaS filter container exists in template!") except Exception as e: print("Fetch service page err:", e)