Skip to content

nlpodyssey/gdelt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GDELT Fetcher

Overview

This package provides tools for fetching and parsing the latest GDELT events data in Go.

Installation

To use this package, import it into your Go project:

go get -u github.com/nlpodyssey/gdelt

Example

package main

import (
	"fmt"
	"time"

	"github.com/nlpodyssey/gdelt"
	"github.com/rs/zerolog/log"
)

func main() {
	log.Info().Msg("getting latest GDELT events")

	events, err := gdelt.FetchLatestEvents(gdelt.DefaultOpts)
	if err != nil {
		log.Fatal().Err(err).Msg("error fetching latest events")
	}

	log.Info().Msgf("processing %d events", len(events))

	for _, event := range events {
		doc := struct {
			EventID     uint64
			URI         string
			Headline    string
			ImageURI    string
			PublishedAt time.Time
		}{
			EventID:     event.GlobalEventID,
			URI:         event.SourceURL,
			Headline:    event.GKGArticle.Extras.PageTitle,
			ImageURI:    event.GKGArticle.SharingImage,
			PublishedAt: event.PublishedAt(),
		}

		fmt.Printf("%+v\n", doc)
	}
}

Contributions

Contributions to this package are welcome.

License

This project is licensed under the Apache License, Version 2.0.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages