import os from bs4 import BeautifulSoup import logging,logging.handlers import traceback import weibo from collections import OrderedDict sys.setdefaultencoding('utf-8') #from MU_conf import MUconf from MU_weibo import post,PrepareLogin from MU_utils import r,unique_str,loggingInit,for_cat,for_rc,_decode_dict os.chdir(os.path.dirname(sys.argv[0])) PUSHEDPREFIX="PUSHED-" EDITEDPREFIX='EDITED-' EXPIRETIME='72*3600' THREEDAYS=259200 log=loggingInit('log/update.log') def GetCategory(title): apiurl="http://zh.moegirl.org/api.php" parmas = urllib.urlencode({'format':'json','action':'query','prop':'categories','titles':title}) req=urllib2.Request(url=apiurl,data=parmas) res_data=urllib2.urlopen(req) ori=res_data.read() categories=json.loads(ori, object_hook=_decode_dict) cat=for_cat(categories) return cat def GetImage(title): try: url="http://zh.moegirl.org/"+title f=urllib.urlopen(url) except: return None
import time import os from bs4 import BeautifulSoup import logging,logging.handlers import traceback import weibo import pdb import re from collections import OrderedDict sys.setdefaultencoding('utf-8') from MU_conf import MU_MainConfig from MU_weibo import post,PrepareLogin from MU_utils import r,unique_str,loggingInit,for_cat,for_rc,_decode_dict import copy os.chdir(os.path.dirname(__file__)) log=loggingInit('../log/update.log') def GetCategory(title): apiurl="https://zh.moegirl.org/api.php" parmas = urllib.urlencode({'format':'json','action':'query','prop':'categories','titles':title}) req=urllib2.Request(url=apiurl,data=parmas) res_data=urllib2.urlopen(req) ori=res_data.read() categories=json.loads(ori, object_hook=_decode_dict) cat=for_cat(categories) return cat def GetImage(title): try: url="https://zh.moegirl.org/"+title f=urllib.urlopen(url) except: return None