def saveText(soup): gistnum = getunicode(soup.find('div',{'class':'path'})).split()[-1] span = soup.find('span',{'class':'code'}) filename = getunicode(span).split()[0] filename = '_'.join([gistnum,filename]) f = open(filename,'w') lines = soup.findAll('div',{'class':'line'}) for line in lines: f.writelines(getPrintUnicode(line)+'\n') f.close() return
def saveText(soup): data_path = soup.find('div',{'class':True,'data-path':True})['data-path'] title = soup.find('title') title = getunicode(title).split()[-3] data_path = os.path.join(os.getcwd(),title,data_path) path, filename = os.path.split(os.path.split(data_path)[0]) makeDir(path) filepath = os.path.join(path, filename) f = open(filepath,'w') lines = soup.findAll('div',{'class':'line'}) for line in lines: f.writelines(getPrintUnicode(line)+'\n') f.close() print filepath, 'saved' return