This Python script, scraper.py, is designed to retrieve flight data from various airline websites using web scraping techniques. It populates flight details and prices into an existing database.
pandasrequestsbeautifulsoup4seleniumpsycopg2 (for PostgreSQL)SQLConn dictionary in the code to match your PostgreSQL connection details.pip install -r requirements.txt.scraper class by instantiating it. Ensure the database connection string is properly set up.getAuditData(): Fetches flight data from the database. This data will be used to construct URLs for scraping.update_flight_amount(row): Scrapes airline websites for flight details and updates the data in the table.main() function to execute the scraping process.scraper ClassgetAuditData(): Fetches flight data from the database.get_html_from_url_bs(url): Retrieves HTML content using requests library.get_html_from_url_selenium(url): Utilizes selenium to access dynamic content and retrieve HTML.requests: For making HTTP requests.beautifulsoup4: For parsing HTML content.pandas: For handling data structures.selenium: For automating web browsers.psycopg2: For PostgreSQL database interaction.requests: For making HTTP requests.BeautifulSoup (from bs4): For HTML parsing.quote (from urllib.parse): For URL encoding.pandas: For handling data structures.create_engine (from sqlalchemy): For database engine creation.datetime: For handling date and time.math: For mathematical operations.webdriver, Service, By, Options (from selenium): For browser automation.time: For handling time-related operations.Content type
Image
Digest
sha256:18de10d7e…
Size
566.2 MB
Last updated
10 months ago
docker pull cerebriai/ptc