Home > Software engineering >  Parsing google alerts using gmail and app script
Parsing google alerts using gmail and app script

Time:05-06

I have google alerts set up and receive alert emails which look like this:

screenshot showing alert

I would like to parse the alert and save it in a google sheet with the format: alert_name,publication_date, title,news source

Not sure where to start any help/guidance appreciated Thanks

CodePudding user response:

You can use the gmail api with appscript the way Results


Note 1: This script is an approximation of the problem, and has only been tested for News related alerts.

Note 2: Thanks to @DalmTo for the pseudo-code, it has helped me to approach the problem more quickly.

Note 3: The hashCode function has been extracted from here

Note 4: I have decided to take an approach using RegExp due to the use of getPlainBody(), but I think that in this case, using a library that allows parsing HTML with getBody() would be easier to implement.

CodePudding user response:

Thanks for the help guys. Google Alerts also output the results in RSS which makes parsing easy! I am using the Feedparser library to parse the RSS and its working superbly.

Thanks again for your help!

  • Related