This guide shows you how to reliably scrape product data from Camping Wagner (campingwagner.de) using the JSON-LD structured data embedded in each product page. By parsing JSON-LD, you get clean, structured fields like name, price, and availability without wrestling with messy HTML. You'll also learn how to build a crawler that respects the site and avoids blocks.
What You'll Need
- Python 3.8+ installed on your machine
- Basic knowledge of Python and command line
- Libraries:
requests,beautifulsoup4,json(built-in), and optionallytimefor delays
Step-by-Step
- Install required libraries
Open your terminal and run:pip install requests beautifulsoup4 - Fetch a single product page
Start with a known product URL (e.g., a tent or sleeping bag). Userequests.get()with a custom User-Agent header to mimic a browser:headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'} response = requests.get(url, headers=headers) - Parse the HTML and extract JSON-LD
Use BeautifulSoup to find all<script type="application/ld+json">tags. These contain the structured data.soup = BeautifulSoup(response.text, 'html.parser') scripts = soup.find_all('script', type='application/ld+json') - Load JSON-LD content
For each script, extract its text and parse withjson.loads(). Sometimes the content is a list or a single object; handle both.for script in scripts: data = json.loads(script.string) if isinstance(data, list): for item in data: process(item) else: process(data) - Extract key product fields
Look for@typethat equals "Product". Then pull fields likename,sku,offers(which contains price and availability),image, anddescription. Example:if data.get('@type') == 'Product': name = data.get('name') offers = data.get('offers', {}) price = offers.get('price') availability = offers.get('availability') - Handle multiple offers or variants
Ifoffersis a list, loop through them to get all variants (e.g., different sizes or colors). Each offer may have its own price and availability. - Implement polite crawling
When scraping multiple pages, add a delay between requests (e.g.,time.sleep(2)) and rotate User-Agents if needed. Check the site'srobots.txtfirst to see allowed paths. - Find product URLs from category pages
To crawl the whole catalog, start from a category page (e.g., /zelte/). Parse the HTML to find links to individual product pages. Usually they are in<a>tags withhrefcontaining a product identifier. Filter out non-product links. - Save data to a file
Collect all products into a list of dictionaries, then write to a JSON file usingjson.dump()with indent for readability.
Common Mistakes
- Ignoring robots.txt – Always check and respect it to avoid legal or ethical issues.
- Not handling JSON-LD as a list – Some pages have multiple JSON-LD blocks (e.g., BreadcrumbList, Product). Your code must iterate correctly.
- Assuming price is always a string – JSON-LD might give price as a string or number; convert to float carefully.
- No error handling – Network errors or missing fields will crash your script. Use try/except and skip missing data.
- Too fast crawling – Sending requests too quickly can get your IP blocked. Always add delays.
Tips
- Use a session –
requests.Session()keeps cookies and headers consistent, which may reduce blocks. - Validate data – Check that the extracted name and price are not empty before saving.
- Log your progress – Print or log each URL being scraped so you can resume if interrupted.
- Cache responses – If you re-run the crawl, consider caching HTML locally to avoid hitting the server repeatedly.
- Respect site structure – Camping Wagner is a German site; product URLs may include category paths. Use that to organize your data.
Troubleshooting
- Getting 403 Forbidden – The site may block default Python User-Agent. Use a real browser User-Agent and add headers like Accept-Language.
- JSON-LD script is empty – Some pages might load content dynamically via JavaScript. In that case, use a headless browser like Selenium or Playwright, but that's heavier.
- No Product type found – Inspect the JSON-LD manually to see if the type is something else (e.g., "ItemPage"). Adjust your filter accordingly.
- Price is missing – Sometimes offers are nested inside a list or have a different structure. Print the raw JSON-LD to debug.
- Script crashes due to encoding – Ensure you set
response.encoding = 'utf-8'or useresponse.textwhich usually handles it.
Frequently Asked Questions
Is it legal to scrape Camping Wagner?
Scraping public data for personal use is generally allowed, but you must respect robots.txt and the site's terms of service. Avoid aggressive crawling that could harm the site.
Do I need an API key?
No, JSON-LD is embedded in the HTML and accessible without any authentication.
What if the site changes its HTML structure?
JSON-LD is a standard format, so it's more stable than HTML. But if they remove it, you'll need to fall back to parsing HTML directly.
Can I scrape images too?
Yes, the JSON-LD often includes an image field with a URL. You can download those images separately if needed.
How do I handle pagination on category pages?
Look for "next" links in the pagination section. Follow them until no next link exists, adding delays between page requests.
What if a product has no JSON-LD?
Some pages might not have structured data. In that case, you'll need to parse the HTML manually using selectors, which is more fragile.