def calc_week_summary(days=7, da=-8 ): """過去days日分の集計(今日を除く昨日まで)""" base_day = datetime.now().date() results = [] for i in range(1+8+da, days + 1+8+da): target_date = base_day - timedelta(days=i) try: df = load_day_data(target_date) date_label = target_date.strftime("%m/%d") summary = calc_daily_summary(df, date_label) results.append(summary) except Exception as e: print(f"{target_date} のデータ読み込み失敗: {e}")
if not results: return None
total_gen = sum(r["gen"] for r in results) total_buy = sum(r["buy"] for r in results) total_sell = sum(r["sell"] for r in results) total_use = sum(r["use"] for r in results)
lines = [f"【過去{days}日間実績】"] for r in reversed(results): # 古い順→新しい順 lines.append(f"{r['date']}: 発電{r['gen']} kWh") lines.append("") lines.append(f"合計発電量: {total_gen:.1f} kWh") lines.append(f"合計買電量: {total_buy:.1f} kWh") lines.append(f"合計売電量: {total_sell:.1f} kWh") lines.append(f"合計消費量: {total_use:.1f} kWh")
11月 29 17:11:53 hsbox mitmdump[47809]: [17:10:04.599][192.168.x.xx:57372] server connect www.frontier-monitor.com:443(150.31.252.104:443) 11月 29 17:11:53 hsbox mitmdump[47809]: [17:10:05.235][192.168.x.xx:57372] Client TLS handshake failed. Client and mitmproxy cannot agree on a TLS version to use. You may need to adjust mitmproxy's tls_version_client_min option. 11月 29 17:11:53 hsbox mitmdump[47809]: [17:10:05.240][192.168.x.xx:57372] client disconnect 11月 29 17:11:53 hsbox mitmdump[47809]: [17:10:05.245][192.168.x.xx:57372] server disconnect www.frontier-monitor.com:443 (150.31.252.104:443) 11月 29 17:11:53 hsbox mitmdump[47809]: [17:10:11.362][192.168.x.xx:43760] client connect 11月 29 17:11:53 hsbox mitmdump[47809]: [17:10:11.469][192.168.x.xx:43760] server connect www.frontier-monitor.com:443 (150.31.252.104:443) 11月 29 17:11:53 hsbox mitmdump[47809]: [17:10:12.019][192.168.x.xx:43760] Client TLS handshake failed. Client and mitmproxy cannot agree on a TLS version to use. You may need to adjust mitmproxy's tls_version_client_min option. 11月 29 17:11:53 hsbox mitmdump[47809]: [17:10:12.023][192.168.x.xx:43760] client disconnect 11月 29 17:11:53 hsbox mitmdump[47809]: [17:10:12.028][192.168.x.xx:43760] server disconnect www.frontier-monitor.com:443 (150.31.252.104:443) 11月 29 17:11:53 hsbox mitmdump[47809]: [17:10:18.092][192.168.x.xx:40724] client connect 11月 29 17:11:53 hsbox mitmdump[47809]: [17:10:18.143][192.168.x.xx:40724] server connect www.frontier-monitor.com:443 (150.31.252.104:443) 11月 29 17:11:53 hsbox mitmdump[47809]: [17:10:18.670][192.168.x.xx:40724] Client TLS handshake failed. Client and mitmproxy cannot agree on a TLS version to use. You may need to adjust mitmproxy's tls_version_client_min option. 11月 29
「Client TLS handshake failed. Client and mitmproxy cannot agree on a TLS version to use. You may need to adjust」このログが大量に出ているが、これが問題だったようだ。 TLS1.0に下げるように要求されている。 hsBoxでも設定で下げれないことはないが、外部公開している入り口が怪しくなるので無理にTLS1.0にさげないことにした。
for th in soup.select(".property_view_table th"): label = th.get_text(strip=True) td = th.find_next_sibling("td") if not td: continue value = td.get_text(strip=True) if "賃料" in label: data["賃料"] = value elif "間取り" in label: data["間取り"] = value elif "面積" in label: data["面積"] = value elif "住所" in label: data["住所"] = value else: # その他の詳細情報も取得 data[label] = value uls = soup.select("#bkdt-option ul.inline_list") for ul in uls: for li in ul.find_all("li"): lis = li.get_text() data["部屋の特徴・設備"] = lis table = soup.select_one("table.data_table.table_gaiyou") results = [] for tr in table.select("tr"): ths = tr.find_all("th") tds = tr.find_all("td")
# th と td の数が合わない場合がある(colspan 特殊ケース) # → そのまま zip せず、柔軟に処理する td_index = 0 for th in ths: th_text = th.get_text(strip=True)
if td_index < len(tds): td = tds[td_index]
# td の中に ul > li があるケース if td.select("ul li"): td_value = "、".join(li.get_text(strip=True) for li in td.select("ul li")) else: td_value = td.get_text(strip=True)
data[th_text] = td_value td_index += 1
for th in soup.select(".data_01 th"): label = th.get_text(strip=True) td = th.find_next_sibling("td") if not td: continue print(f"{th} {td}\n") print(td) value = td.get_text(strip=True) if "賃料" in label: data["賃料"] = value elif "間取り" in label: data["間取り"] = value elif "面積" in label: data["面積"] = value elif "住所" in label: data["住所"] = value else: data[label] = value
required_keys = ["所在地", "駅徒歩", "間取り", "築年数", "向き","専有面積","建物種別","部屋の特徴・設備"] missing_count = sum(1 for k in required_keys if not data.get(k))
if missing_count >= 2: error_msg = f"【詳細ページ解析異常】\nURL: {url}\n欠損項目: {[k for k in required_keys if not data.get(k)]}" ifttt_line_notify([error_msg], page_type="詳細ページ", extra="必須項目欠損")