alex9smith / gdelt-doc-api

A Python client for the GDELT 2.0 Doc API
MIT License
91 stars 20 forks source link

Can we use Keyword for multiple Search queries? #24

Closed MostafaBouzari closed 1 year ago

MostafaBouzari commented 1 year ago

Hello and tnx for creating this Library. wanted to know if i can search more than one keyword at the same time like top 10 German Companies. keyword = "Volkswagen OR BMW OR Siemens OR Bosch OR Allianz OR Bayer OR Daimler OR BASF OR Deutsche Bank OR SAP"

it would help me a lot if you could provide some examples tnx

MostafaBouzari commented 1 year ago

Found the code, sry for confusion.

from gdeltdoc import GdeltDoc, Filters

Define the search term

keyword = ["Volkswagen","Siemens", "Bosch", "Allianz", "Bayer", "Daimler"]

Define the date range

start_date = "2020-01-01" end_date = "2023-04-28"

Create search filters object

for i in keyword: filters = Filters(keyword=keyword, start_date=start_date, end_date=end_date)

Create GdeltDoc object

gd = GdeltDoc()

Search for articles matching the filters

articles = gd.article_search(filters)