News Feed Forums General Web Scraping How to extract fundraiser details from GoFundMe.com using Python?

  • How to extract fundraiser details from GoFundMe.com using Python?

    Posted by Lenz Dominic on 12/20/2024 at 9:38 am

    Scraping fundraiser details from GoFundMe.com using Python can be helpful for analyzing campaigns, such as gathering information on titles, goals, and amounts raised. By using Python’s requests library for sending HTTP requests and BeautifulSoup for parsing HTML, you can efficiently extract relevant data. The process involves sending a GET request to the page, parsing the HTML response, and targeting elements containing the fundraiser details. Below is a sample Python script for scraping fundraisers from GoFundMe.

    import requests
    from bs4 import BeautifulSoup
    # Target URL for GoFundMe campaigns
    url = "https://www.gofundme.com/discover"
    headers = {
        "User-Agent": "Mozilla/5.0"
    }
    response = requests.get(url, headers=headers)
    if response.status_code == 200:
        soup = BeautifulSoup(response.content, "html.parser")
        campaigns = soup.find_all("div", class_="campaign-card")
        for campaign in campaigns:
            title = campaign.find("h3").text.strip() if campaign.find("h3") else "Title not available"
            goal = campaign.find("span", class_="goal").text.strip() if campaign.find("span", class_="goal") else "Goal not available"
            raised = campaign.find("span", class_="raised").text.strip() if campaign.find("span", class_="raised") else "Amount raised not available"
            print(f"Title: {title}, Goal: {goal}, Raised: {raised}")
    else:
        print("Failed to fetch GoFundMe page.")
    

    This script extracts titles, funding goals, and amounts raised from GoFundMe campaigns. It can be extended to handle pagination by identifying and navigating through additional campaign pages. Adding random delays between requests reduces the risk of being detected by anti-scraping measures. Proper error handling ensures smooth operation even when elements are missing.

    Lenz Dominic replied 2 days, 15 hours ago 1 Member · 0 Replies
  • 0 Replies

Sorry, there were no replies found.

Log in to reply.