aboutsummaryrefslogtreecommitdiffstats
path: root/bemani/sdvx.py
diff options
context:
space:
mode:
authorPinapelz <yukais@pinapelz.com>2025-04-12 00:18:23 -0700
committerPinapelz <yukais@pinapelz.com>2025-04-12 00:18:23 -0700
commitdc0794ae2c08a35c30ae8de2d44e2a21c7875252 (patch)
tree110b4c0f636c099038e5d5e39b27c4d165f9d867 /bemani/sdvx.py
init commit
Diffstat (limited to 'bemani/sdvx.py')
-rw-r--r--bemani/sdvx.py46
1 files changed, 46 insertions, 0 deletions
diff --git a/bemani/sdvx.py b/bemani/sdvx.py
new file mode 100644
index 0000000..55d97ef
--- /dev/null
+++ b/bemani/sdvx.py
@@ -0,0 +1,46 @@
+from bs4 import BeautifulSoup
+from datetime import datetime
+from urllib.parse import urljoin
+
+def parse_exceed_gear_news_site(html: str, base_url: str):
+ soup = BeautifulSoup(html, 'html.parser')
+ news_list = soup.select('.tab ul.news li')
+
+ entries = []
+ for li in news_list:
+ date = li.select_one('strong')
+ pre = li.select_one('pre')
+
+ if not date or not pre:
+ continue
+ date_str = date.text.strip()
+ try:
+ dt = datetime.strptime(date_str, "%Y.%m.%d")
+ timestamp = int(dt.timestamp())
+ except ValueError:
+ timestamp = None
+ headline = li.select_one('p.notice')
+ headline_text = headline.text.strip() if headline else None
+ for tag in pre.select('font, b, u, span'):
+ tag.unwrap()
+ content = pre.get_text(separator='\n', strip=True)
+ images = []
+ for img in pre.select('img'):
+ src = img.get('data-original') or img.get('src')
+ if not src or src.startswith('data:'):
+ continue
+ src = urljoin(base_url, src)
+ parent = img.find_parent('a')
+ href = urljoin(base_url, parent['href']) if parent and parent.has_attr('href') else None
+ images.append({'image': src, 'link': href})
+
+ entries.append({
+ 'date': date_str,
+ 'type': None,
+ 'timestamp': timestamp,
+ 'headline': headline_text,
+ 'content': content,
+ 'images': images
+ })
+
+ return entries
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage