mc_screenshot



In [9]:
import json
import subprocess
import os

In [7]:
with open ('/tmp/json2', 'rb') as json_file:
    json_string = json_file.read()
    #print json_file.read()
    popular_queries = json.loads( json_string )


Out[7]:
[{u'count': 291,
  u'dashboard_action': u'/view/1',
  u'dashboards_id': 1,
  u'popular_queries_id': 1002,
  u'queries_id_0': 56936,
  u'queries_id_1': 56941,
  u'query_0_description': u'in Top 25 Mainstream Media during the week starting 2011-05-23',
  u'query_1_description': u'in Political Blogs during the week starting 2011-05-23',
  u'url_params': u'?q2=56941&q1=56936'},
 {u'count': 168,
  u'dashboard_action': u'/view/1',
  u'dashboards_id': 1,
  u'popular_queries_id': 859,
  u'queries_id_0': 55418,
  u'queries_id_1': 55446,
  u'query_0_description': u'in Top 25 Mainstream Media during the week starting 2011-05-09',
  u'query_1_description': u'in Political Blogs during the week starting 2011-05-09',
  u'url_params': u'?q2=55446&q1=55418'}]

In [2]:
os.chdir('/home/dlarochelle/git_dev/mediacloud/screen_shots')
os.chdir('top_1000')
         
subprocess.check_output(['phantomjs', '../../screen_shot_arguments.js', '94684', ''] )


Out[2]:
'capturing\n94684\nhttp://www.mediacloud.org/dashboard/view/1?q1=94684\ncapture_and_render: http://www.mediacloud.org/dashboard/view/1?q1=94684&q2=\nrenderinghttp://www.mediacloud.org/dashboard/view/1?q1=94684&q2=\nbase_name:mc_94684_\ncaptured\n'

In [11]:
os.chdir('/home/dlarochelle/git_dev/mediacloud/screen_shots')

dirs = ['top_10', 'top_100', 'top_1000', 'all']

dirs = [ 'top_10']
for dir in dirs:
    print "processing {}".format( dir )
    os.chdir( dir )
    with open ('pop_queries.json', 'rb') as json_file:
        json_string = json_file.read()
        #print json_file.read()
        popular_queries = json.loads( json_string )
        for popular_query in popular_queries:
            q0 = popular_query[ 'queries_id_0' ]
            q1 = popular_query[ 'queries_id_1' ]
            if q1 == None:
                q1 = ''
            subprocess.check_output( ['phantomjs', '../screen_shot_arguments.js', str(q0), str(q1) ] )
            subprocess.check_output( ['phantomjs', '../screen_shot_arguments.js', str(q0), str(q1), '--wc_only' ] )
            subprocess.check_output( ['phantomjs', '../screen_shot_arguments.js', str(q0), str(q1), '--cmap_only' ] )
            print q0, q1
    os.chdir( '../')


processing top_10
94946 
42981 
88321 
43376 
87843 
89128 
90007 
94176 
57768 
59047 

In [7]:
os.chdir('/home/dlarochelle/git_dev/mediacloud/screen_shots')

dirs = ['top_10', 'top_100', 'top_1000', 'all']
dirs = [ 'top_100']
for dir in dirs:
    print "processing {}".format( dir )
    os.chdir( dir )
    with open ('pop_queries.json', 'rb') as json_file:
        json_string = json_file.read()
        #print json_file.read()
        popular_queries = json.loads( json_string )
        for popular_query in popular_queries:
            q0 = popular_query[ 'queries_id_0' ]
            q1 = popular_query[ 'queries_id_1' ]
            if q1 == None:
                q1 = ''
            if q1:
                print "http://www.mediacloud.org/dashboard/view/1?q1={}&q2={}".format( q0, q1)
            else:
                #print "http://www.mediacloud.org/dashboard/view/1?q1={}".format( q0, q1)
                pass


processing top_100
http://www.mediacloud.org/dashboard/view/1?q1=56936&q2=56941
http://www.mediacloud.org/dashboard/view/1?q1=55418&q2=55446
http://www.mediacloud.org/dashboard/view/1?q1=42968&q2=42969
http://www.mediacloud.org/dashboard/view/1?q1=54541&q2=54542
http://www.mediacloud.org/dashboard/view/1?q1=93382&q2=93467
http://www.mediacloud.org/dashboard/view/1?q1=56615&q2=56911
http://www.mediacloud.org/dashboard/view/1?q1=59132&q2=59133

In [ ]: