<s> import json <EOL> import zmq <EOL> import requests <EOL> from lxml import etree <EOL> def get_title ( url ) : <EOL> """<STR_LIT>""" <EOL> r = requests . get ( url ) <EOL> tree = etree . HTML ( r . content ) <EOL> title = tree . xpath ( '<STR_LIT>' ) <EOL> if title : <EOL> return title [ <NUM_LIT:0> ] <EOL> else : <EOL> return None <EOL> context = zmq . Context ( ) <EOL> receiver = context . socket ( zmq . PULL ) <EOL> receiver . connect ( "<STR_LIT>" ) <EOL> sender = context . socket ( zmq . PUSH ) <EOL> sender . connect ( "<STR_LIT>" ) <EOL> while True : <EOL> s = receiver . recv ( ) <EOL> title = get_title ( s ) <EOL> print s , title <EOL> sender . send ( json . dumps ( { "<STR_LIT:url>" : s , "<STR_LIT:title>" : title } ) ) </s>
