26.12.2013 Aufrufe

Zensursula und negative Verantwortungsattribution - Netzpolitik

Zensursula und negative Verantwortungsattribution - Netzpolitik

Zensursula und negative Verantwortungsattribution - Netzpolitik

MEHR ANZEIGEN
WENIGER ANZEIGEN

Sie wollen auch ein ePaper? Erhöhen Sie die Reichweite Ihrer Titel.

YUMPU macht aus Druck-PDFs automatisch weboptimierte ePaper, die Google liebt.

Anhang 1 – Der Topsy-Crawler<br />

integer, trackback_date text, trackback_author_nick text, url text, title text, firstpost_date<br />

text, content text, mytype text, score real, topsy_author_img text, highlight text,<br />

trackback_author_url text, trackback_permalink text, topsy_author_url text,<br />

trackback_author_name text, topsy_trackback_url text, searchterm text,<br />

firstpost_date_timestamp text, PRIMARY KEY (trackback_date, url))'<br />

c.execute(sql_query)<br />

except sqlite3.OperationalError, e:<br />

table_name = table_name + '_' + str(time.time()).replace('.','')<br />

create_new_db_table()<br />

# inserts a tupel into the database<br />

def insert_db(i):<br />

insert(i['hits'], i['trackback_total'], i['trackback_date'],<br />

i['trackback_author_nick'], i['url'], i['title'], i['firstpost_date'], i['content'],<br />

i['mytype'], i['score'], i['topsy_author_img'], i['highlight'], i['trackback_author_url'],<br />

i['trackback_permalink'], i['topsy_author_url'], i['trackback_author_name'], searchterm,<br />

i['topsy_trackback_url'])<br />

# executes the insert command<br />

def insert(hits, trackback_total, trackback_date, trackback_author_nick, url, title,<br />

firstpost_date, content, mytype, score, topsy_author_img, highlight, trackback_author_url,<br />

trackback_permalink, topsy_author_url, trackback_author_name, searchterm,<br />

topsy_trackback_url):<br />

sql_query = 'insert into ' + table_name + ' values<br />

(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)'<br />

c.execute(sql_query, [hits, trackback_total, trackback_date, trackback_author_nick,<br />

url, title, firstpost_date, content, mytype, score, topsy_author_img, highlight,<br />

trackback_author_url, trackback_permalink, topsy_author_url, trackback_author_name,<br />

topsy_trackback_url, searchterm, to_timestamp(firstpost_date)])<br />

conn.commit()<br />

### main<br />

# opens a database connection<br />

conn = sqlite3.connect(db_path)<br />

c = conn.cursor()<br />

if print_request_info:<br />

topsy_response = execute_query(get_request_limit())<br />

print_request_limit_information(topsy_response)<br />

if print_response_info:<br />

topsy_response = execute_query(get_request(tstart, tend, searchterm, page, type,<br />

perpage))<br />

print_response_information(topsy_response)<br />

if create_new_table:<br />

create_new_db_table()<br />

print 'Created Table: ' + table_name<br />

# calculates the number of time windows<br />

window_count = 1<br />

window_number = ((tend - tstart) / request_window) + 1<br />

print 'Window number: ' + str(window_number)<br />

results = Queue()<br />

threads = []<br />

t1, t2 = set_window(tstart)<br />

# processes all time time windows<br />

while(t2 < tend):<br />

thread = Timewindow_Crawler(t1, t2, window_count, results)<br />

threads.append(thread)<br />

thread.start()<br />

t1, t2 = set_window(t2)<br />

window_count += 1<br />

# processes the last time window<br />

thread = Timewindow_Crawler(t1, tend, window_count, results)<br />

threads.append(thread)<br />

thread.start()<br />

# wait for all threads<br />

for t in threads:<br />

t.join()<br />

write_to_database(results)<br />

c.close<br />

conn.close()<br />

108/148

Hurra! Ihre Datei wurde hochgeladen und ist bereit für die Veröffentlichung.

Erfolgreich gespeichert!

Leider ist etwas schief gelaufen!