In [1]:
import mediacloud, datetime

In [ ]:
#Default key: The variable 'key' must be edited according to the specific mediacloud user
key = 'ed673300791e2d3b3f3f1ddb933da2c11fc57bfded8781d049c95be511d90fcd'
mc = mediacloud.api.MediaCloud(key)

In [ ]:
#Comparison of the number of stories written about 'Trump' and 'Clinton' in September 20176 
res = mc.sentenceCount('Trump', solr_filter=[mc.publish_date_query( datetime.date( 2016, 9, 1), datetime.date( 2016, 10, 1) ), 'tags_id_media:1' ])
res2 = mc.sentenceCount('Clinton', solr_filter=[mc.publish_date_query( datetime.date( 2016, 9, 1), datetime.date( 2016, 10, 1) ), 'tags_id_media:1' ])
person = 'Trump' if res['count'] > res2['count'] else 'Clinton'
print 'The US Mainstream Media sources talked more about', person, 'in the September 2016.'