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]:
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]:
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( '../')
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
In [ ]: