What is Google Alerts?
For those who are not familiar with Google Alerts - it is a simple service which lets you create kind of "Internet Watcher" for given search terms.
Some of the search term you can create a watcher for:
- "STEEM OR SBD OR steemit"
- "Donald Trump"
Go google.com/alerts and give it a try.
The only one problem with the service, is that Google does not provide a public API for it.
That is why I created an nodejs wrapper for the service which allows you to manage your alerts within npm package.
I have been writing about the service almost a year ago. At the time, I faced a problem with authentication process. This time, Google has changed alert model, so it required additional changes to the library - which is the scope of the contribution. Entire process of creating, fetching and modifying alerts has changed. The problem itself was raised on this github issue by package user.
The way Google serializes alerts for the sake of HTTP communication is really tough to read. Here is an example:
In order to build human readable alert object there needs to be defined special mappers:
Such mappers says us, where given alert attribute (
id, etc.) are being located. I.e. alert's name (
NAME_LOC = '1.2.0') stands for:
- Go to array element with index
- Inside the array search for array located on index
- Inside found array, on the first position (index
0) there is an alert name.
Almost all of them has been updated due to the google changes. What is more, in order to get alerts I had to change the way an alerts state is being parsed:
Modifying / creating API requests has been updated as well. More details in PR.
What is more, a complete set of test for modifing alerts has been added (sorry for an incorrect screenshot indention)
We are no longer able to authenticate within mail / password, so a new function for generating cookies has been added.
See unit test:
How to get
SSID? Entire process is described in
According to the PR changes, version
0.4.2 has been published to the npm registry.