def get_douban_site(): with open('data/intro') as i: intro = json.loads(i.read()) with open('data/info') as i: info = json.loads(i.read()) with open('data/meta') as i: meta = json.loads(i.read()) #zs = ZsiteLink.where(link='http://site.douban.com/110633/(1号厅的光影传奇)') #if zs: # zs = zs[0] # zs.link = 'http://site.douban.com/110633/' # zs.save() for zl in ZsiteLink.where(name='豆瓣小站').order_by('id desc').col_list(col='zsite_id'): if not Rss.where(user_id=zl): zs = ZsiteLink.raw_sql('select link from zsite_link where link like %s and zsite_id=%s and cid=2', 'http://site.douban.com%', zl).fetchone() if zs: id = zs[0].split('/')[-1] or zs[0].split('/')[-2] if info.get(id): like, link, img, name = info.get(id) if meta.get(id): motto = meta.get(id)[0][0] motto = motto.split('<br />')[0] motto = motto.split('<a')[0] img_src = meta.get(id)[0][1] rss_new(zl, 'http://rss-tidy.42qu.com/douban/site/%s'%id, name, link, auto=1) print zl, 'http://site.douban.com/%s'%id else: print id, 'no motto data' else: print id, '数据未录入', zl
def validate_link(id, cid, link): pure_link = link[7:].strip("@") try: if ord(pure_link[0]) > 127 or "@" in pure_link: print pure_link print "" except: pass if pure_link.isalnum(): print "id:%s cid:%s EX:%s" % (id, cid, pure_link) pure_link = OAUTH2URL[cid] % pure_link print pure_link print "" ZsiteLink.raw_sql("update zsite_link set link=%s where id=%s", pure_link, id)
def validate_link(id, cid, link): pure_link = link[7:].strip('@') try: if ord(pure_link[0]) > 127 or '@' in pure_link: print pure_link print '' except: pass if pure_link.isalnum(): print 'id:%s cid:%s EX:%s' % (id, cid, pure_link) pure_link = OAUTH2URL[cid] % pure_link print pure_link print '' ZsiteLink.raw_sql('update zsite_link set link=%s where id=%s', pure_link, id)
def validate_all_links(): c = ZsiteLink.raw_sql("select id, cid, link from zsite_link where cid=2 or cid=3 or cid=4 or cid=8") x = c.fetchall() for i in x: id = i[0] cid = i[1] link = i[2] validate_link(id, cid, link)
def validate_all_links(): c = ZsiteLink.raw_sql( 'select id, cid, link from zsite_link where cid=2 or cid=3 or cid=4 or cid=8' ) x = c.fetchall() for i in x: id = i[0] cid = i[1] link = i[2] validate_link(id, cid, link)
def get_uri(): from model.zsite_link import ZsiteLink from model.zsite import Zsite, ZSITE_STATE_VERIFY ids = Zsite.raw_sql('select id from zpage.zsite where cid = %s' , CID_USER).fetchall() links = [] for id in ids: r = ZsiteLink.raw_sql('select link from zpage.zsite_link where zsite_id = %s and cid in (0,2)', *id).fetchall() for link in r: links.append([id[0], link[0]]) return links
def get_douban_site(): with open('data/intro') as i: intro = json.loads(i.read()) with open('data/info') as i: info = json.loads(i.read()) with open('data/meta') as i: meta = json.loads(i.read()) #zs = ZsiteLink.where(link='http://site.douban.com/110633/(1号厅的光影传奇)') #if zs: # zs = zs[0] # zs.link = 'http://site.douban.com/110633/' # zs.save() for zl in ZsiteLink.where(name='豆瓣小站').order_by('id desc').col_list( col='zsite_id'): if not Rss.where(user_id=zl): zs = ZsiteLink.raw_sql( 'select link from zsite_link where link like %s and zsite_id=%s and cid=2', 'http://site.douban.com%', zl).fetchone() if zs: id = zs[0].split('/')[-1] or zs[0].split('/')[-2] if info.get(id): like, link, img, name = info.get(id) if meta.get(id): motto = meta.get(id)[0][0] motto = motto.split('<br />')[0] motto = motto.split('<a')[0] img_src = meta.get(id)[0][1] rss_new(zl, 'http://rss-tidy.42qu.com/douban/site/%s' % id, name, link, auto=1) print zl, 'http://site.douban.com/%s' % id else: print id, 'no motto data' else: print id, '数据未录入', zl
def make_site(name, link, motto, img_src, site_num, current_user_id=10017321): f = urllib.urlopen(img_src).read() if f: pic = picopen(f) if pic: pic_id = site_ico_new(10017321, pic) site = site_new(name, current_user_id, 40) site_id = site.id site_ico_bind(current_user_id, pic_id, site_id) zsite_link = ZsiteLink.get_or_create(zsite_id=site_id, cid=2) zsite_link.link = link zsite_link.name = '豆瓣小站' zsite_link.save() mc_flush(site_id) motto_set(site_id, motto) rss_new(site_id, 'http://rss-tidy.42qu.com/douban/site/%s'%site_num, name, link, auto=1) print site_id
def make_site(name, link, motto, img_src, site_num, current_user_id=10017321): f = urllib.urlopen(img_src).read() if f: pic = picopen(f) if pic: pic_id = site_ico_new(10017321, pic) site = site_new(name, current_user_id, 40) site_id = site.id site_ico_bind(current_user_id, pic_id, site_id) zsite_link = ZsiteLink.get_or_create(zsite_id=site_id, cid=2) zsite_link.link = link zsite_link.name = '豆瓣小站' zsite_link.save() mc_flush(site_id) motto_set(site_id, motto) rss_new(site_id, 'http://rss-tidy.42qu.com/douban/site/%s' % site_num, name, link, auto=1) print site_id