<s> """<STR_LIT>""" <EOL> import urllib <EOL> from BeautifulSoup import BeautifulSoup <EOL> import urlparse , httplib , random , string <EOL> def getHostName ( url ) : <EOL> hostName = urlparse . urlparse ( url ) [ <NUM_LIT:1> ] . split ( '<STR_LIT:.>' ) <EOL> return hostName [ - <NUM_LIT:2> ] + '<STR_LIT:.>' + hostName [ - <NUM_LIT:1> ] <EOL> def soup_get_links ( data , mytype , mywhat ) : <EOL> soup = BeautifulSoup ( data ) <EOL> mytab = [ ] <EOL> linki_pl = soup . find ( mytype , mywhat ) <EOL> if linki_pl : <EOL> tag_a = linki_pl . findAll ( '<STR_LIT:a>' ) <EOL> if len ( tag_a ) > <NUM_LIT:0> : <EOL> for mytag in tag_a : <EOL> myt1 = '<STR_LIT>' <EOL> if len ( mytag . text ) > <NUM_LIT:0> : <EOL> myt1 = mytag . text <EOL> else : <EOL> myt1 = getHostName ( mytag [ '<STR_LIT>' ] ) <EOL> mytab . append ( { "<STR_LIT>" : mytag [ '<STR_LIT>' ] , "<STR_LIT:text>" : myt1 , "<STR_LIT:id>" : mywhat } ) <EOL> return mytab </s>
