fix: KöPi - Bild auto-height, warte auf alle Bilder vor Screenshot

This commit is contained in:
2026-07-09 12:00:22 +02:00
parent 5c05a2fc7d
commit 2a06e93e90
2 changed files with 9 additions and 3 deletions

View File

@@ -64,7 +64,13 @@ async function scrapeMarktguru() {
await page.goto('https://www.marktguru.de/search/k%C3%B6nig%20pilsener?zipCode=47259', {
waitUntil: 'networkidle2', timeout: 30000,
});
await new Promise(r => setTimeout(r, 4000));
// Warte bis alle Bilder geladen sind
await page.evaluate(() => Promise.all(
Array.from(document.querySelectorAll('img.offer-list-item-img')).map(img =>
img.complete ? Promise.resolve() : new Promise(r => { img.onload=r; img.onerror=r; setTimeout(r,5000); })
)
)).catch(() => {});
await new Promise(r => setTimeout(r, 2000));
const offers = await page.evaluate(() => {
// Exakte Selektoren basierend auf marktguru HTML-Struktur

View File

@@ -36,9 +36,9 @@ function OfferCard({ offer }) {
}}>
{/* Bild oben, volle Breite */}
{offer.image && (
<div style={{ margin:'-12px -14px 8px -14px', height:180, background:'#111', borderRadius:'8px 8px 0 0', overflow:'hidden', display:'flex', alignItems:'center', justifyContent:'center' }}>
<div style={{ margin:'-12px -14px 8px -14px', borderRadius:'8px 8px 0 0', overflow:'hidden', background:'#1a1a1a', display:'flex', alignItems:'center', justifyContent:'center' }}>
<img src={offer.image} alt="König Pilsener"
style={{ maxWidth:'100%', maxHeight:'100%', objectFit:'contain' }}
style={{ width:'100%', height:'auto', display:'block' }}
onError={e => { e.target.parentElement.style.display='none'; }}
/>
</div>