import DGStorage as DGS a = DGS.DGStorage() a.select('biology') ok = False i = 0 while ok == False: res = a.fetch(20, (i - 1) * 20) i += 1 if len(res) == 0: ok = True for item in res: a.setprop(item["uid"], "printed", "no") print('set ' + item["prop"]["name"])
import DGStorage as DGS; dbhandle=DGS.DGStorage(); dbhandle.create("/var/lib/bipt");
import DGStorage as DGS dbHandle = DGS.DGStorage() dbHandle.select("/var/lib/bipt") dbHandle.add( "5120150743", "宋亚意", { "name": "宋亚意", "id": 5120150743, "music": "Whistle", "praise": 0, "pic": None, "phone": "?!?", "description": "来自计153班" })
import DGStorage as DG import subprocess; import os; import time; a=DG.DGStorage() def checkout(web): subprocess.check_output('wget --user-agent="Links (2.8; Linux 2.6.32-504.30.3.el6.x86_64 x86_64; GNU C 4.4.7; text)" --output-document=tmp -q "'+str(web)+'"',shell=True); a.create('yuwenpoint') a.select('yuwenpoint') i=1; while i<=184: checkout('http://www.mofangge.com/qlist/yuwen/'+str(i)); print(i); with open('tmp') as cont: a.add(i,cont.read()); i+=1; os.remove('tmp'); time.sleep(3); print('done'); b=DG.DGStorage() b.create('yingyupoint') b.select('yingyupoint') i=1; while i<=333: checkout('http://www.mofangge.com/qlist/yingyu/'+str(i)); print(i); with open('tmp') as cont: b.add(i,cont.read()); i+=1; os.remove('tmp');
import DGStorage as D a=D.DGStorage() a.select('swpoint'); a.zip('biology');
import DGStorage as DG; import urllib.parse; a=DG.DGStorage(); type='biology'; a.select(type); b=DG.DGStorage(); b.select('knowledgebase'); ok=False; i=0; while ok==False: res=a.fetch(20,(i-1)*20); i+=1; if len(res)==0: ok=True; content=[]; for item in res: split=item["content"].split('\n'); split=split[38].split('●'); #print(len(split)); if len(split)==31: #超过一页了,最后一项是分页 split=split[1:-1]; split=split[0:4]; #要不然题太多了 for element in split: element=element.split('</a>')[0]; #print(element.find('.html">')); url=element[element.find('<a href=')+9:element.find('.html">')+5]; element=element[element.find('.html">')+7:element.find('</a>')-1]; #print(element); content.append(element); b.add(url,'',{"content":element,"type":type,"kbname":item["prop"]["name"],"kb":item["uid"]}); print('add '+item["uid"]);
from pyfetch import * import DGStorage as DG import time import urllib.parse import os a = DG.DGStorage() a.select('knowledgebase') ok = False i = 199 while ok == False: res = a.fetch(20, (i - 1) * 20) i += 1 if i == 399: ok = True if len(res) == 0: ok = True for item in res: fetch(urllib.parse.unquote_plus(item["key"]), 'tmp') with open('tmp') as cont: a.put(item["uid"], cont.read()) os.remove('tmp') print('put cont ' + item["uid"]) time.sleep(3) print('DONE==================================================')