#!/usr/bin/env python3 """Build combined Joomla article from 4 Prime Day deal files.""" import re import json def extract_deal_blocks(html_content): """Extract all deal div blocks from HTML content.""" # Find all deal div blocks (flex containers with images) blocks = re.findall( r'
(.*?)
\s*', html_content, re.DOTALL ) # Also try the card class variant from devices file if not blocks: blocks = re.findall( r'
(.*?)
\s*', html_content, re.DOTALL ) return blocks def extract_deal_blocks_full(html_content): """Extract full deal div blocks including the outer div.""" blocks = re.findall( r'(
.*?
\s*)', html_content, re.DOTALL ) if not blocks: blocks = re.findall( r'(
.*?
\s*)', html_content, re.DOTALL ) return blocks def extract_deal_blocks_devices(html_content): """Extract deal blocks from the devices file (uses class='card').""" blocks = re.findall( r'
(.*?)
(?=\s*(?:

|

|))', html_content, re.DOTALL ) return blocks def convert_device_block_to_standard(block_html): """Convert a device card block to standard deal format.""" # Extract image img_match = re.search(r'(.*?)', block_html) title = title_match.group(1) if title_match else '' # Extract price price_match = re.search(r'(.*?)', block_html) price = price_match.group(1) if price_match else '' # Extract UVP uvp_match = re.search(r'(.*?)', block_html) uvp = uvp_match.group(1) if uvp_match else '' # Extract badge (discount %) badge_match = re.search(r'(.*?)', block_html) badge = badge_match.group(1) if badge_match else '' # Extract link link_match = re.search(r']*>Zu Amazon →', block_html) link = link_match.group(1) if link_match else '' # Calculate savings savings = '' if price and uvp: try: price_val = float(price.replace('€', '').replace(',', '.').strip()) uvp_val = float(uvp.replace('UVP ', '').replace('€', '').replace(',', '.').strip()) saved = round(uvp_val - price_val, 2) savings = f'({saved:.2f} € gespart)' except: pass # Build standard block block = f'''

{title}
{price} {uvp} {badge}''' if savings: block += f'\n{savings}' block += f'
\nZu Amazon →
' return block def main(): # Read all 4 files files = { 'mass_market': '/home/hermes/workspace/amazon_deals_2026-06-23.html', 'kennerspiele': '/home/hermes/workspace/kennerspiele_deals_2026-06-23.html', 'top_deals': '/home/hermes/workspace/top_deals_2026-06-23.html', 'devices': '/home/hermes/workspace/amazon_devices_prime_2026-06-23.html', } contents = {} for key, path in files.items(): with open(path, 'r') as f: contents[key] = f.read() # Extract deal blocks from each file mass_market_blocks = extract_deal_blocks_full(contents['mass_market']) kennerspiele_blocks = extract_deal_blocks_full(contents['kennerspiele']) # For top_deals, extract blocks by category top_html = contents['top_deals'] # Extract sections from top_deals # Heißluftfritteusen hf_section = re.search(r']*>Heißluftfritteusen.*?

(.*?)(?=]*>Staubsauger.*?(.*?)(?=]*>Laptops.*?(.*?)(?=]*>Tablets.*?(.*?)(?=]*>Smartphones.*?(.*?)(?=]*>Apple.*?(.*?)(?=

Prime Days Sommer 2026: Die große Brettspiel- & Technik-Deal-Übersicht') article.append('') article.append('

Die Amazon Prime Days Sommer 2026 sind da! Wir haben für euch die besten Deals aus den Bereichen Brettspiele, Kennerspiele, Haushaltselektronik und Technik zusammengestellt. Insgesamt erwarten euch über 100 Angebote — von familienfreundlichen Brettspiel-Klassikern über anspruchsvolle Kennerspiele mit BGG-Ranking bis hin zu Heißluftfritteusen, Staubsaugern, Laptops, Tablets, Smartphones und Apple-Produkten. Alle Preise sind Momentaufnahmen und können sich schnell ändern — also schnell zugreifen!

') article.append('') article.append('
') article.append('') # Section 1: Kennerspiele article.append('

🔥 Kennerspiele mit BGG-Ranking

') article.append('

Für alle Vielspieler und Strategen: Hier kommen die anspruchsvolleren Brettspiele mit BGG-Weight-Rating. Viele davon sind exklusive Prime-Day-Angebote (⚡) — also nur für Prime-Mitglieder!

') article.append('') for block in kennerspiele_blocks: article.append(block) article.append('') # Section 2: Mass-Market Brettspiele article.append('

🎲 Alle Brettspiel-Angebote

') article.append('

Familienspiele, Klassiker und Partyspiele — hier ist für jeden Spieleabend etwas dabei. Von Monopoly über Catan bis hin zu UNO und Trivial Pursuit.

') article.append('') for block in mass_market_blocks: article.append(block) article.append('') # Section 3: Heißluftfritteusen article.append('

🍟 Heißluftfritteusen

') article.append('

Knusprig, schnell und energiesparend: Die besten Airfryer-Deals der Prime Days. Von Tefal über Ninja bis Philips — hier sind die Top-Angebote.

') article.append('') for block in hf_blocks: article.append(block) article.append('') # Section 4: Staubsauger article.append('

🧹 Staubsauger & Wischroboter

') article.append('

Saugroboter, Akku-Staubsauger und klassische Bodenstaubsauger — die besten Deals für ein sauberes Zuhause.

') article.append('') for block in st_blocks: article.append(block) article.append('') # Section 5: Laptops article.append('

💻 Laptops

') article.append('

Notebooks und Laptops für Arbeit, Studium und Freizeit — mit kräftigen Rabatten zum Prime Day.

') article.append('') for block in lp_blocks: article.append(block) article.append('') # Section 6: Tablets article.append('

📱 Tablets

') article.append('

Android-Tablets und Samsung Galaxy Tabs — perfekt für Unterhaltung unterwegs.

') article.append('') for block in tb_blocks: article.append(block) article.append('') # Section 7: Smartphones article.append('

📱 Smartphones

') article.append('

Samsung, Xiaomi und Motorola — die besten Smartphone-Deals zum Prime Day.

') article.append('') for block in sp_blocks: article.append(block) article.append('') # Section 8: Apple article.append('

🍎 Apple-Produkte

') article.append('

iPhones und iPads zu reduzierten Preisen — die besten Apple-Deals der Prime Days.

') article.append('') for block in ap_blocks: article.append(block) article.append('') # Section 9: Amazon Devices & Gaming article.append('

📦 Gaming & Zubehör

') article.append('

Gaming-Headsets, Controller, Nintendo Switch 2 und weiteres Zubehör — die besten Deals für Gamer.

') article.append('') for block in device_blocks: article.append(block) article.append('') # Footer article.append('

Quellen: Amazon.de über CreatorAPI. Preise Stand 23.06.2026 07:00 Uhr. Preise und Verfügbarkeit können sich schnell ändern. Über die Partner-Links (Tag 60pro05-21) kauft ihr zum gleichen Preis — Amazon zahlt eine kleine Provision.

') full_article = '\n'.join(article) # Split at readmore parts = full_article.split('
') introtext = parts[0].strip() + '\n
' fulltext = parts[1].strip() if len(parts) > 1 else '' # Save the article with open('/home/hermes/workspace/combined_article_introtext.html', 'w') as f: f.write(introtext) with open('/home/hermes/workspace/combined_article_fulltext.html', 'w') as f: f.write(fulltext) with open('/home/hermes/workspace/combined_article_full.html', 'w') as f: f.write(full_article) print(f"\nIntrotext length: {len(introtext)} chars") print(f"Fulltext length: {len(fulltext)} chars") print(f"Total article length: {len(full_article)} chars") # Save JSON payload for Joomla API payload = { "title": "Prime Days Sommer 2026: Die große Brettspiel- & Technik-Deal-Übersicht", "introtext": introtext, "fulltext": fulltext, "catid": 61, "state": 0, "access": 6, "created_by": 560, "language": "de", "featured": 0 } with open('/home/hermes/workspace/joomla_payload.json', 'w') as f: json.dump(payload, f, ensure_ascii=False, indent=2) print("\nPayload saved to joomla_payload.json") if __name__ == '__main__': main()