Пример #1
0
 def signIn(self,groupName,city = u"武汉市", country = u"中国",province = u"湖北省",latitude = 30.452684,longitude = 114.431715,position = u"在烽火通信高新四路研发中心签到啦!"):
     textData = {
         "city":city,
         "country":country,
         "groupId":self.getGroupId(groupName),
         "imei":"qrre/poND6REBvagI60UNA\u003d\u003d",
         "latitude":latitude,
         "longitude":longitude,
         "msgId":"APP086",
         "position":position,
         "province":province,
         "token":"",
         "userId":self.__loginResponse__["resultMap"]["userInfo"]["id"],
         "userName":self.__loginResponse__["resultMap"]["userInfo"]["name"]
     }
     #textData["userId"] = 100
     reqData = {"text":json.dumps(textData)}
     req = urllib2.Request(url = self.__signUrl__,data = urllib.urlencode(reqData),headers = self.__headers__)
     res_data = urllib2.urlopen(req)
     response = json.loads(res_data.read())
     if '0' == response["code"]:
         log4j.info("success")
         return 0
     else:
         log4j.error("faild to signIn " + str(groupName) + ",reason:" + response["message"])
         return -1
Пример #2
0
 def login(self):
     textData = {
         "device":"FRD-AL00",
         "mobile":self.__userName__,
         "msgId":"APP129",
         "password":self.md5(self.__userPass__),
         "pushType":1,
         "registrationId":"180bfe837d914d67a61ab3b89015cb13",
         "system":"7.0",
         "systemType":"1",
         "version":self.__yqVer__
     }
     reqData = {"text":json.dumps(textData)}
     headers = self.__headers__
     req = urllib2.Request(url = self.__loginUrl__,data = urllib.urlencode(reqData),headers = headers)
     res_data = urllib2.urlopen(req)
     content = res_data.read()
     # fp = open(self.__userCacheFile__, 'w')
     # fp.write(content)
     # fp.close()
     self.__loginResponse__ = json.loads(content)
     if '0' == self.__loginResponse__["code"]:
         self.__headers__["YQ-Token"] = self.__loginResponse__["resultMap"]["userInfo"]["usertoken"]
         log4j.info("login success,token:" + self.__headers__["YQ-Token"])
         return 0
     else:
         log4j.error("login failed,reason:" +  self.__loginResponse__["message"])
         return -1
Пример #3
0
 def articlePreview(self, article_info):
     ret = -1
     if 4 == article_info["objectType"]:
         textData = {
             "articleId":article_info["id"],
             "isShow":"true",
             "msgId":"ARTICLE_DETAIL",
             "userId":self.__loginResponse__["resultMap"]["userInfo"]["id"]
         }
         requestUrl = "http://iyouqu.com.cn:8080/app/magazine/service.do"
     elif 1 == article_info["objectType"] or 3 == article_info["objectType"]:
         textData = {
             "msgId":"APP009",
             "objectId":article_info["id"],
             "opinion":0,
             "userId":self.__loginResponse__["resultMap"]["userInfo"]["id"]
         }
         requestUrl = "http://iyouqu.com.cn:8080/app/newsActivity/service.do"
     else:
         log4j.error("error:unkown objectType:" + str(article_info["objectType"]))
         return
     reqData = {"text":json.dumps(textData)}
     try:
         req = urllib2.Request(url = requestUrl,data = urllib.urlencode(reqData),headers = self.__headers__)
         res_data = urllib2.urlopen(req)
         response = json.loads(res_data.read())
         if '0' != response["code"]:
             log4j.error("faild to preview <" + str(article_info["title"]) + ">,reason:" + response["message"])
         else:
             log4j.info("success")
             ret = 0
     except Exception as ex:
         print ex
     return ret
Пример #4
0
 def articleVote(self,keyWord):
     articleInfo = self.getArticleInfo(keyWord)
     if None == articleInfo:
         return
     if 4 == articleInfo["objectType"]:
         textData = {
             "articleId":articleInfo["id"],
             "msgId":"ARTICLE_VOTE",
             "userId":self.__loginResponse__["resultMap"]["userInfo"]["id"]
         }
         requestUrl = "http://iyouqu.com.cn:8080/app/magazine/service.do"
     elif 1 == articleInfo["objectType"] or 3 == articleInfo["objectType"]:
         textData = {
             "msgId":"APP010",
             "objectId":articleInfo["id"],
             "opinion":0,
             "userId":self.__loginResponse__["resultMap"]["userInfo"]["id"]
         }
         requestUrl = "http://iyouqu.com.cn:8080/app/newsActivity/service.do"
     else:
         log4j.error("error:unkown objectType:" + str(articleInfo["objectType"]))
         return
     reqData = {"text":json.dumps(textData)}
     req = urllib2.Request(url = requestUrl,data = urllib.urlencode(reqData),headers = self.__headers__)
     res_data = urllib2.urlopen(req)
     response = json.loads(res_data.read())
     if '0' == response["code"]:
         log4j.info("success")
     else:
         log4j.error("faild to vote article:<" + str(articleInfo["title"]) + ">,reason:" + response["message"])
Пример #5
0
 def getGroupId(self,name=""):
     if self.__groupInfo__ is None:
         self.updateGroupList()
     groupList = self.__groupInfo__
     # print groupList
     for group in groupList:
         if name == group["name"]:
             return int(group["id"])
     log4j.error("specified group:" + str(name) + " is not found")
     return None
Пример #6
0
def login():
    url = "http://202.103.24.68:90/login"
    reqData = {
        "uri":"",
        "terminal":"pc",
        "login_type":"login",
        "check_passwd":"0",
        "show_tip":"block",
        "show_change_password":"******",
        "short_message":"none",
        "show_captcha":"none",
        "show_read":"block",
        "show_assure":"none",
        "username":common.mail_addr[0:common.mail_addr.index('@')],
        "assure_phone":"",
        "password1":"do not need,password is in md6 format",
        "password":encrypt.md6(common.mail_pw),
        "new_password":"",
        "retype_newpassword":"",
        "captcha_value":"",
        "save_user":"******",
        "save_pass":"******",
        "read":"1"
    }
    headers = {
        "User-Agent":"Mozilla/5.0 (Windows NT 6.1; WOW64; rv:54.0) Gecko/20100101 Firefox/54.0",
        "Content-Type":"application/x-www-form-urlencoded"
    }
    rv_code = -1
    try:

        req = urllib2.Request(url = url,data = urllib.urlencode(reqData),headers = headers)
        res_data = urllib2.urlopen(req)
        content =  res_data.read()
        if r"submitbutton('logout')" in content:
            log4j.info("login success")
            rv_code  = 0
        else:
            log4j.error("login faild:" + content)
    except Exception as ex:
       log4j.error("login faild:" + ex)
    return rv_code
Пример #7
0
 def getArticleInfo(self,keyWord):
     if self.__articleMap__.has_key(keyWord):
         return self.__articleMap__[keyWord]
     textData = {
         "department":"02A20000",
         "index":"0",
         "keyword":keyWord[0:5],
         "msgId":"APP011",
         "userId":self.__loginResponse__["resultMap"]["userInfo"]["id"]
     }
     reqData = {"text":json.dumps(textData)}
     req = urllib2.Request(url = "http://iyouqu.com.cn:8080/app/newsActivity/service.do",data = urllib.urlencode(reqData),headers = self.__headers__)
     res_data = urllib2.urlopen(req)
     response = json.loads(res_data.read())
     if '0' == response["code"]:
         articleList = response["resultMap"]["newsList"]
         if 0 == len(articleList):
             log4j.error("no search result")
             return None
         for i in range(0,len(articleList)):
             articleInfo = articleList[i]
             if keyWord in articleInfo["title"]:
                 self.__articleMap__[keyWord] = articleInfo
                 log4j.info("matched article:" + articleInfo["title"] + ",objectType:" + str(articleInfo["objectType"]))
                 return articleInfo
         log4j.error("error:cannot match " + keyWord + " in search result")
         return None
     else:
         log4j.error(response["message"])
         return None
Пример #8
0
 def __getLatestArticles(self, index):
     textData = {
         "department":"02A20000",
         "index":str(index),
         "msgId":"APP150",
         "categoryId":"-1",
         "categoryType":"0",
         "userId":self.__loginResponse__["resultMap"]["userInfo"]["id"]
     }
     reqData = {"text":json.dumps(textData)}
     req = urllib2.Request(url = "http://iyouqu.com.cn:8080/app/newsActivity/service.do",data = urllib.urlencode(reqData),headers = self.__headers__)
     res_data = urllib2.urlopen(req)
     response = json.loads(res_data.read())
     if '0' == response["code"]:
         articles = response["resultMap"]["objectList"]
         # for article in articles:
         #     print(article)
         #     print("-" * 80)
         return articles
     else:
         log4j.error(response["message"])
         return None
Пример #9
0
 def articleComment(self,keyWord,comment = u"赞"):
     articleInfo = self.getArticleInfo(keyWord)
     if None == articleInfo:
         return
     if 1 == articleInfo["objectType"] or 3 == articleInfo["objectType"]:
         targetId = 2
     else:
         targetId = articleInfo["objectType"]
     textData = {
         "content":comment,
         "msgId":"APP039",
         "targetId":articleInfo["id"],
         "targetType":targetId,
         "userId":self.__loginResponse__["resultMap"]["userInfo"]["id"]
     }
     reqData = {"text":json.dumps(textData)}
     req = urllib2.Request(url = "http://iyouqu.com.cn:8080/app/service.do",data = urllib.urlencode(reqData),headers = self.__headers__)
     res_data = urllib2.urlopen(req)
     response = json.loads(res_data.read())
     print response
     if '0' == response["code"]:
         log4j.info("success")
     else:
         log4j.error("faild to vote commemt:<" + articleInfo["title"] + ">,reason:" + response["message"])