<commit_before>#!/usr/bin/python2.6  
# -*- coding: utf-8 -*-  
#encoding=utf-8
'''
Created on 2014年6月9日

@author: kerry
'''
from base.http import MIGHttpMethodGet,MIGHttpMethodPost
import base.util as util
import json
from xml.etree import ElementTree

class RobotInfoMgr(object):
    '''
    classdocs
    '''
    '''
    def print_node(self,node):
        print "============================"
        print "node.attrib:%s" % node.attrib
        print "node.tag:%s" % node.tag
        print "node.text:%s" % node.text
      '''          

    def __init__(self):
        '''
        Constructor
        '''
    def __GetRobotInfo(self,index,count):
        url = "http://192.168.3.11/cgi-bin/getrobots.fcgi?from="+str(index)+"&count="+str(count)
        host ="192.168.3.11"
        http = MIGHttpMethodGet(url,host)
        http.HttpMethodGet()
        result,content = util.MIGGetResult(http.HttpGetContent())
        if(result==1):
            return content
        else:
            print "GetResult Error"
    
    def __GetVipUserHead(self,index,count):
        
        content_list = [0 for i in range(0)]
        
        url = "http://www.5show.com/webservice.asmx/GetVipAlbumList?pageIndex="+str(index)+"&pageSize="+str(count)
        host ="www.5show.com"
        print url
        http = MIGHttpMethodGet(url,host)
        http.HttpMethodGet()
        #print http.HttpGetContent()
        root = ElementTree.fromstring(http.HttpGetContent())
        lst_node = root.getiterator("userheadpic")
        for node in lst_node:
            content_list.append(node.text)
        
        return content_list
    
    def __GetAlbumUserHead(self,index,count):
        
        content_list = [0 for i in range(0)]
        
        url = "http://www.5show.com/webservice.asmx/GetAlbumList?pageIndex="+str(index)+"&pageSize="+str(count)
        host ="www.5show.com"
        print url
        http = MIGHttpMethodGet(url,host)
        http.HttpMethodGet()
        #print http.HttpGetContent()
        root = ElementTree.fromstring(http.HttpGetContent())
        lst_node = root.getiterator("userheadpic")
        for node in lst_node:
            content_list.append(node.text)
        
        return content_list
       
    def __GetRobotId(self,index,count):
        content_list = [0 for i in range(0)]
        content = self.__GetRobotInfo(index,count)
        for element in content:
            content_list.append(element["id"])
        
        return content_list
         
    def UpdateUserHeadUrl(self):
        #index = 0
        count = 100
        i = 0
        j = 0
        vip_len = 0
        while (j<20000):
            index = j
            content_json_list = [0 for i in range(0)]
            content_list_id = self.__GetRobotId(count,index)
            content_list_url = self.__GetVipUserHead(index+1, count)
            if(len(content_list_url)==0):
                content_list_url = self.__GetAlbumUserHead(index+1-vip_len, count)
            else:
                vip_len = len(content_list_url)
            print content_list_id
            print content_list_url
            print "================"
            if(len(content_list_id)==0 or len(content_list_url)==0):
                break
            
            if len(content_list_id) < len(content_list_url):
                now_len = len(content_list_id) 
            else:
                now_len = len(content_list_url)
            print now_len
            while (i < now_len):
                info = {}
                info["id"] = content_list_id[i]
                info["url"] = content_list_url[i]
                print info
                content_json_list.append(info)
                i = i+1
            url = "http://192.168.3.11/cgi-bin/updaterobotpic.fcgi"
            data ="content="+str(json.dumps(content_json_list))
            host = "192.168.3.11"
            http = MIGHttpMethodPost(url,host)
            http.HttpMethodPost(data=data)
            http.HttpGetContent()
            j = j + count
            i= 0
        
            
        
        
        
        <commit_msg>* 将获取用户西悉尼HTTP请求封装到接口中<commit_after>#!/usr/bin/python2.6  
# -*- coding: utf-8 -*-  
#encoding=utf-8
'''
Created on 2014年6月9日

@author: kerry
'''
from base.http import MIGHttpMethodGet,MIGHttpMethodPost
import base.util as util
import json
from xml.etree import ElementTree
from base.httpinterface import MigHttpInterFace

class RobotInfoMgr(object):
    '''
    classdocs
    '''
    '''
    def print_node(self,node):
        print "============================"
        print "node.attrib:%s" % node.attrib
        print "node.tag:%s" % node.tag
        print "node.text:%s" % node.text
      '''          

    def __init__(self):
        '''
        Constructor
        '''
    def __GetRobotInfo(self,index,count):
        return MigHttpInterFace.GetRobotInfo(index, count)
    
    def __GetVipUserHead(self,index,count):
        
        content_list = [0 for i in range(0)]
        
        url = "http://www.5show.com/webservice.asmx/GetVipAlbumList?pageIndex="+str(index)+"&pageSize="+str(count)
        host ="www.5show.com"
        print url
        http = MIGHttpMethodGet(url,host)
        http.HttpMethodGet()
        #print http.HttpGetContent()
        root = ElementTree.fromstring(http.HttpGetContent())
        lst_node = root.getiterator("userheadpic")
        for node in lst_node:
            content_list.append(node.text)
        
        return content_list
    
    def __GetAlbumUserHead(self,index,count):
        
        content_list = [0 for i in range(0)]
        
        url = "http://www.5show.com/webservice.asmx/GetAlbumList?pageIndex="+str(index)+"&pageSize="+str(count)
        host ="www.5show.com"
        print url
        http = MIGHttpMethodGet(url,host)
        http.HttpMethodGet()
        #print http.HttpGetContent()
        root = ElementTree.fromstring(http.HttpGetContent())
        lst_node = root.getiterator("userheadpic")
        for node in lst_node:
            content_list.append(node.text)
        
        return content_list
       
    def __GetRobotId(self,index,count):
        content_list = [0 for i in range(0)]
        content = self.__GetRobotInfo(index,count)
        for element in content:
            content_list.append(element["id"])
        
        return content_list
         
    def UpdateUserHeadUrl(self):
        #index = 0
        count = 100
        i = 0
        j = 0
        vip_len = 0
        while (j<20000):
            index = j
            content_json_list = [0 for i in range(0)]
            content_list_id = self.__GetRobotId(count,index)
            content_list_url = self.__GetVipUserHead(index+1, count)
            if(len(content_list_url)==0):
                content_list_url = self.__GetAlbumUserHead(index+1-vip_len, count)
            else:
                vip_len = len(content_list_url)
            print content_list_id
            print content_list_url
            print "================"
            if(len(content_list_id)==0 or len(content_list_url)==0):
                break
            
            if len(content_list_id) < len(content_list_url):
                now_len = len(content_list_id) 
            else:
                now_len = len(content_list_url)
            print now_len
            while (i < now_len):
                info = {}
                info["id"] = content_list_id[i]
                info["url"] = content_list_url[i]
                print info
                content_json_list.append(info)
                i = i+1
                
            MigHttpInterFace.UpdateRobotHead(str(json.dumps(content_json_list)))
            j = j + count
            i= 0
        
            
        
        
        
        
{'fraction_non_alphanumeric': 0.11571630840520016, 'fraction_numerical': 0.015317286652078774, 'mean_word_length': 1.8223755902651653, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 8, 'xml': 2}, 'pii_count': 4, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3905986', 'n_tokens_mistral': 2454, 'n_tokens_neox': 2380, 'n_words': 417}