Categorygithub.com/antodippo/flight-scraper
modulepackage
0.0.0-20230531163708-b90e9bc9a5e4
Repository: https://github.com/antodippo/flight-scraper.git
Documentation: pkg.go.dev

# README

Flight scraper

Build Release Go Report License: MIT

It's a simple flight prices scraper written in Go. Given a route and a date, it's gonna query Kayak.com website, parse the page, and send the information to the provided email recipient.

The simplest way to use it is to download it for your operating system and run:

$ ./flight-scraper -departure=FCO -arrival=AMS -date=2020-06-15 [email protected],[email protected]

where:

  • departure and arrival are IATA airport codes
  • date is in YYYY-MM-DD format
  • recipient is the email recipient

At the moment you also need to set up an email SMTP server, adding the environment variables in the .env file.

Use the .env.dist file as a reference:

SMTP_FROM="Flights scraper <[email protected]>"
SMTP_HOST=smtp.sendgrid.net
SMTP_PORT=587
SMTP_USER=myusername
SMTP_PWD=mypassword

This is similar to what you get as a result in your email:

RouteTimeAirlinePrice
FCO - AMS15:30 - 18:00easyJet76€
FCO - AMS10:30 - 13:05LEVEL81€
FCO - AMS19:35 - 22:10LEVEL97€
FCO - AMS8:35 - 11:05Alitalia109€
FCO - AMS14:05 - 16:35Alitalia109€
FCO - AMS6:30 - 8:50KLM143€
FCO - AMS19:40 - 22:05KLM143€
FCO - AMS12:40 - 15:10KLM143€
FCO - AMS10:20 - 12:55KLM143€
FCO - AMS17:25 - 20:00KLM143€

A possible use is to run it as a cron job, so you get flight prices in your inbox every chosen amount of time.

This was build just for learning and experimentation purposes, before using it please read Kayak.com terms and conditions.

# Functions

BuildResultsHTMLTemplate build an HTML template for results and return it as string.
FetchAndStorePage fetches a web page and stores its content.
No description provided by the author
LogErrorIfNotNull prints and logs an error if err not null.
LogFatalAndExitIfNotNull prints an logs and error and exits if err not null.
LogInfo prints and logs a string.
LogWarning prints and logs a string.
ParseFlags parses input flags.
ParseKayakResults parses results in an html page.
SendEmailNotification sends an HTML email notification.
StoreJSONQueries stores a list of queries in a json file.
StoreJSONResults stores a list of results in a json file.

# Structs

FlightResult is a representation of a single result.
No description provided by the author
SearchInput is a representation of the input request.
No description provided by the author
No description provided by the author

# Interfaces

No description provided by the author