modulepackage
0.0.0-20230531163708-b90e9bc9a5e4
Repository: https://github.com/antodippo/flight-scraper.git
Documentation: pkg.go.dev
# README
Flight scraper
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
andarrival
are IATA airport codesdate
is in YYYY-MM-DD formatrecipient
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:
Route | Time | Airline | Price |
---|---|---|---|
FCO - AMS | 15:30 - 18:00 | easyJet | 76€ |
FCO - AMS | 10:30 - 13:05 | LEVEL | 81€ |
FCO - AMS | 19:35 - 22:10 | LEVEL | 97€ |
FCO - AMS | 8:35 - 11:05 | Alitalia | 109€ |
FCO - AMS | 14:05 - 16:35 | Alitalia | 109€ |
FCO - AMS | 6:30 - 8:50 | KLM | 143€ |
FCO - AMS | 19:40 - 22:05 | KLM | 143€ |
FCO - AMS | 12:40 - 15:10 | KLM | 143€ |
FCO - AMS | 10:20 - 12:55 | KLM | 143€ |
FCO - AMS | 17:25 - 20:00 | KLM | 143€ |
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