Python Web Scraper for Events CSV Export
This prompt helps you get the job done faster: "Python Web Scraper for Events CSV Export". Copy the ready-to-paste prompt, fill in the bracketed details for your situation, and run it in your AI tool for a high-quality first draft you can refine in minutes.
The prompt
You are a Python developer tasked with writing a production-ready web scraper. Your job is to write a complete, working Python script that: 1. Fetches the HTML content from a public event webpage 2. Parses the HTML to extract event dates and locations 3. Validates and cleans the extracted data 4. Exports the results to a well-formatted CSV file with proper headers **Target URL:** [WEBPAGE_URL] **Events structure:** [DESCRIBE_HOW_EVENTS_ARE_STRUCTURED_ON_PAGE] (e.g., "Each event is in a <div class='event-card'> with date in an h2 and location in a paragraph below it") **Required output columns:** date, location, [OPTIONAL_ADDITIONAL_FIELDS] **Constraints and requirements:** - Use only standard library modules (requests, BeautifulSoup4, csv, datetime) for maximum compatibility - Handle missing or malformed data gracefully (use fallback values like "TBD") - Parse dates into consistent YYYY-MM-DD format - Save output to [OUTPUT_FILENAME].csv in the current working directory - Include error handling for network timeouts and parsing failures - Add comments explaining each major section - The script should complete without user interaction once run **Output format:** Python script (.py file) with: - Clear imports at the top - A main() function that orchestrates the workflow - Separate helper functions for fetching, parsing, and saving - Docstrings for all functions - A "if __name__ == '__main__':" guard at the bottom Before writing code, outline the 3-4 key parsing steps in pseudocode so I can verify the logic is sound.
How to use it
- 1Choose your AI tool (Claude, ChatGPT, Gemini, etc.) and open a new chat. Copy the entire prompt above and paste it into the chat window.
- 2Fill in the [PLACEHOLDER] values: the actual event webpage URL you want to scrape, a description of how events are structured in the HTML (inspect the page using your browser's Developer Tools to identify the CSS selectors or HTML tags), optional extra fields you want to extract (event title, price, etc.), and your desired CSV filename.
- 3Run the first response: the AI will outline its parsing strategy. Review the pseudocode and ask clarifying questions if the approach doesn't match the page structure. Once you approve, ask it to write the full script.
- 4Copy the generated Python script into a .py file on your computer. Install required dependencies by running `pip install requests beautifulsoup4` in your terminal.
- 5Before running the script in production, test it on a small subset: run the script and check that the output CSV has correct dates/locations. If parsing fails, inspect the actual HTML with `curl [URL] | head -50` or your browser dev tools, then ask the AI to adjust the selectors.
- 6Once working, schedule the script to run automatically using cron (macOS/Linux) or Task Scheduler (Windows), or integrate it into a workflow tool like Zapier or Make for recurring scrapes.
Recommended tools
Want this built and running in your stack?
Hacking Demand builds HubSpot Breeze + Claude AI agents that put prompts like this to work end-to-end.
See how we build AI agentsRelated prompts
Frequently asked
What does the "Python Web Scraper for Events CSV Export" prompt do?
This prompt helps you get the job done faster: "Python Web Scraper for Events CSV Export". Copy the ready-to-paste prompt, fill in the bracketed details for your situation, and run it in your AI tool for a high-quality first draft you can refine in minutes.
Which AI tool is this prompt for?
It works in any AI assistant. Paste it into ChatGPT, Claude, Gemini, or your tool of choice and adjust the formatting if needed.
How do I use this prompt?
Copy the prompt, replace any bracketed placeholders with your own details, and paste it into your AI assistant. Then follow the setup steps on this page to refine the output.
Want a prompt tailored to your exact task?
Remix this in the builder →