<s> import sys , random <EOL> import machine <EOL> from pattern . en import tag <EOL> from pattern . web import Bing , SEARCH , IMAGE , URL , extension <EOL> def save_image ( url , figure ) : <EOL> url = URL ( url ) <EOL> f = open ( '<STR_LIT>' + figure + extension ( url . page ) , '<STR_LIT:wb>' ) <EOL> f . write ( url . download ( ) ) <EOL> f . close ( ) <EOL> text = sys . stdin . read ( ) <EOL> invention = machine . Invention ( text ) <EOL> engine = Bing ( license = None ) <EOL> search_base = "<STR_LIT>" <EOL> for i , illustration in enumerate ( invention . unformatted_illustrations ) : <EOL> search_string = '<STR_LIT>' + str ( i + <NUM_LIT:1> ) + search_base <EOL> print "<STR_LIT>" + search_string <EOL> for j , result in enumerate ( engine . search ( search_string , type = IMAGE , count = <NUM_LIT:5> ) ) : <EOL> print "<STR_LIT>" + result . url <EOL> try : <EOL> save_image ( result . url , "<STR_LIT>" + str ( i + <NUM_LIT:1> ) + "<STR_LIT:_>" + str ( j + <NUM_LIT:1> ) ) <EOL> except : <EOL> next </s>
