import urllib
from bs4 import BeautifulSoup

params = urllib.urlencode({'spam': 1, 'eggs': 2})
f = urllib.urlopen("http://localhost/?%s" % params)

print f.read()

@@ -41,123 +41,1109 @@
 oup%0A
-%0Aparams = urllib.urlencode(%7B'spam': 1, 'eggs': 2%7D)%0Af = urllib.urlopen(%22http://localhost/?%25s%22 %25 params
+import json%0Aimport bs4%0Aimport time%0A%0A%0A# get a Table as input%0A# return stored snp/infos as a JSON object%0Adef getSnp(tbl):%0A    %22%22%22%0A%0A    :type tbl: bs4.element.Tag%0A    %22%22%22%0A    snp = %7B%7D%0A    for row in tbl.find_all('tr'):%0A%0A        th = row.th.string%0A%0A        if hasattr(row.td, 'contents'):%0A            td = row.td.contents.__str__()%0A        else:%0A            td = 'NULL'%0A%0A        # if td != 'NULL':%0A        #     td = BeautifulSoup(td,'html.parser').get_text()%0A%0A        snp%5Bth%5D = td%0A%0A    return snp%0A%0A%0A# list of all snps%0Alst = %5B%5D%0A%0Afor ID in range(0, 220):%0A    page = urllib.urlopen(%22http://XXXXX?id=%25s%22 %25 ID)%0A    doc = BeautifulSoup(page, 'html.parser')%0A    table = doc.table%0A    if table:%0A        # print table%0A        lst.append(getSnp(table))%0A    # use sleep to prevent DoS or blocking by IPS%0A    # time.sleep(1
 )%0A%0A
+# 
 print 
-f.read
+lst%0A# print '________________'%0A# print%0A# print json.dumps(lst)%0A%0A%0A# Storing%0Atarget = open('result_pretty.json', 'w')%0Atarget.truncate()%0Atarget.write(json.dumps(lst,indent=4))%0Atarget.close()%0A%0Atarget = open('result.json', 'w')%0Atarget.truncate()%0Atarget.write(json.dumps(lst))%0Atarget.close
 ()%0A

exporting to json is OK