Skip to content

Instantly share code, notes, and snippets.

@rahulbot
Last active February 22, 2018 01:03
Show Gist options
  • Save rahulbot/ca51db8f7e5489bbbc0080dd1af31f13 to your computer and use it in GitHub Desktop.
Save rahulbot/ca51db8f7e5489bbbc0080dd1af31f13 to your computer and use it in GitHub Desktop.
Using MediaCloud to query for coverage in media or collections
keywords = "inequality"
sources = [28, # Miami Helard
39] # South Florida Sun Sentinel
collections = [38379430] # Florida state & local
mc = mediacloud.api.AdminMediaCloud(API_KEY)
# how many sentences have used this word in the last 3 months?
print(mc.sentenceCount(keywords, ["media_id: ({})".format(" ".join(map(str, sources))),
'publish_date:NOW to NOW-3MONTH']))
# how many stories have used this word in the last 3 months?
print(mc.storyCount(keywords, ["media_id: ({})".format(" ".join(map(str, sources))),
'publish_date:NOW to NOW-3MONTH']))
# how many stories in the Florida state & local colleciton used this word in 2017
print(mc.storyCount(keywords, ["tags_id_media: ({})".format(" ".join(map(str, collections))),
"publish_date:[2017-01-01T00:00:00Z TO 2018-01-01T00:00:00Z]"]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment