[Python] What is the best way to extract the full list of worldwide addresses from the Sappi...

Discussão em 'Python' iniciado por Stack, Agosto 26, 2025.

  1. Stack

    Stack Membro Participativo

    I want get all worldwide addresses for this website.

    import requests
    from bs4 import BeautifulSoup
    import pandas as pd

    url = "https://www.sappi.com/en-gb/about-us/locations"
    response = requests.get(url)
    soup = BeautifulSoup(response.text, 'html.parser')

    # Find all cards for locations
    location_cards = soup.find_all('div', class_='coh-list-container coh-unordered-list')

    data = []
    for card in location_cards:
    name = card.find('h3').get_text(strip=True) if card.find('h3') else ""
    address = card.find('div', class_='location-address').get_text(strip=True) if card.find('div', class_='location-address') else ""
    country = card.find('div', class_='location-country').get_text(strip=True) if card.find('div', class_='location-country') else ""
    data.append({
    'Name': name,
    'Address': address,
    'Country': country
    })

    # Convert to DataFrame and export to Excel
    df = pd.DataFrame(data)
    df.to_excel('sappi_locations.xlsx', index=False)
    print("Data exported to sappi_locations.xlsx")

    Continue reading...

Compartilhe esta Página