How roshanalokhande/bms-web-scraping- works
Project type and purpose
• This is an open-source Python web-scraping tool.
• Purpose: Automatically extract event details (name, venue, category, price, image URL, etc.) from the BookMyShow website for a user-specified city and save results to Excel (and raw HTML for debugging).
File structure
• Top-level files:
• README.md – project description and instructions
• main.py – entry point and orchestration
• requirements.txt – dependency list
• No frontend/backend split or microservices; it’s a single-service CLI tool.
README for insights
• Uses undetected_chromedriver & Selenium to drive Chrome and avoid bot-detection.
• Parses HTML with BeautifulSoup.
• Stores data via pandas/openpyxl into an Excel file.
• Saves raw HTML snapshots.
• Handles dynamic loading (scrolling) and error conditions (CAPTCHAs, timeouts).
Components & relationships
a. Main Components
1. User CLI (main.py)
2. undetected_chromedriver + Selenium (Browser Automation)
3. External BookMyShow Website (Target)
4. BeautifulSoup Parser
5. Data Layer (pandas → Excel file)
6. Debug Layer (raw HTML file)
7. Error/Retry Handler
b. Data Flow & Interactions
• User invokes main.py with city parameter.
• main.py launches undetected_chromedriver → spins up Chrome.
• Selenium navigates to BookMyShow URL → browser renders dynamic content.
• Browser automation scrolls, waits, handles CAPTCHAs/timeouts (Error Handler).
• Page source (raw HTML) is passed to BeautifulSoup.
• BeautifulSoup extracts structured event details.
• Parsed data fed into pandas DataFrame → written to bookmyshow_<city>events.xlsx.
• Raw HTML also written to disk for debugging.
c. Architectural Patterns & Design Principles
• Pipeline pattern: data flows through stages (fetch → parse → store).
• Separation of concerns:
• Fetching & rendering (Selenium)
• Parsing (BeautifulSoup)
• Persistence (pandas/openpyxl)
• Error handling (retry, CAPTCHA detection)
• Extensibility point: city parameter → can adapt to other pages or websites.
d. Key Technologies & Frameworks
• Python 3.8+
• undetected_chromedriver (manages ChromeDriver invisibly)
• Selenium WebDriver (dynamic content handling)
• BeautifulSoup4 (HTML parsing)
• pandas & openpyxl (data storage to Excel)
Detail is key
• Every stage: user input → browser launch → scrolling → HTML capture → parsing → storage → error handling.
• Don’t over-modularize—this is a single-service tool—but clearly separate logical steps.