Giter Club home page Giter Club logo

communauto-search's Introduction

This is a Python tool script to automate the search of a Communauto near me (Montreal)

It is linked to a Google Sheet, Sendgrid API and run through a Heroku dyno

I imagined it so that it run easily on my Heroku dyno but still can be used locally if needed

#Setup You need a Sendgrid (Free) account with a registered email address on it

You need to set you environment with these variables :

  • communauto_user : the username to connect to the platform
  • communauto_pwd : the password to connect to the platform
  • communauto_mailto : the address who will recieve the emails (or python list of addresses)
  • communauto_from : the Sendgrid registered sender email

If you run through Heroku, you can use instead :

  • heroku config:set communauto_user=USER communauto_pwd=PASSWORD communauto_mailto=EMAIL communauto_from=FROM Otherwise you can add them as environment variables in your IDE or your code

There is few files that are needed amongst the code :

  • A communauto-slots.csv Google Sheet file who keep the user input needs
    • The Google Sheet can be replaced with a CSV called communauto-slots.csv file
    • The header should be in both cases : StartYear,StartMonth,StartDay,StartHour,StartMinute,EndYear,EndMonth,EndDay,EndHour,EndMinute
    • You have to grant access to you Google API to your file. Follow this tutorial : https://developers.google.com/identity/protocols/oauth2/service-account
    • If you choose to store it in Google Drive, call the sheet communauto-slots
  • A gdrive_client_secret.json only if you use Google Drive of course
    • You can have the file locally, or an environment variable called gdrive_client_secret containing the json (for a public usecase on Heroku)
  • A results.json file will be created and modified to store new results. To compare old/new results and send mail for new ones.
    • If you run locally, everything is fine, it you run on Heroku, you should add a env var gdrive_results to 1 so that it create/look for results file on Gdrive.

Script phases every X minutes :

  • Loads dates and hours of need from the file (Google Sheet or local csv)
  • Connect and login with the credentials from the env variables
  • Do the POST form requests for each timeslot
  • Scrap available cars number + place + type + km to home
  • Compare results with saved results for each timeslot in the json file
  • Send email if better change for each timeslot

TODO :

  • Dynamic form filling depending the webpage shown
  • Try to keep session alive to avoid login each time

communauto-search's People

Contributors

alarty avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.