Ejemplo n.º 1
0
    def get_hc_special(self,url):
        ''' 以登录状态获取mouser页面 '''
        fun     = 'function get_hc_special'
        try:
            ''' url 测试而已 '''
            ns          = get_now()
            ''' 下面两句: 前句为默认的语句;  后句为修改后 加上pangtong访问代理前缀  edit by daimingming 2013年 01月 07日 星期一 15:04:30 CST '''
            req         = liulanqi.Request(url)#test
            #req         = liulanqi.Request(get_pangtong_proxy_url(url))#test
            #req.host = ''
            #req.headers=''
            try:
                req_open    = liulanqi.urlopen(req)
                hc          = req_open.read()
                info_url    = req_open.geturl()
            except Exception,e:
                hc          = 'timeout'
                info_url    = url
            ''' 获取此时真实的url响应url '''
            hc          = '<info_url>%s</info_url>' % str(info_url) + str(hc)
            
            res_logout = self.p_logout.findall(hc)
            if res_logout:
                ''' 匹配到 1 登出 or 2 Log Out 链接 '''
                ne      = get_now()
                if debug:print 'get html in %s s on access' % str(ne - ns)
            else:
                ''' 没有匹配到 登出 链接 '''
                if debug:print '没有匹配到 登出/Log Out 链接 所以再次登录'
                self.login()
            
                ''' 下面两句: 前句为默认的语句;  后句为修改后 加上pangtong访问代理前缀  edit by daimingming 2013年 01月 07日 星期一 15:04:30 CST '''
                req = liulanqi.Request(url)
                #req = liulanqi.Request(get_pangtong_proxy_url(url))

                req_open = liulanqi.urlopen(req)
                hc = req_open.read()
                info_url = req_open.geturl()
                hc = '<info_url>%s</info_url>' % str(info_url) + str(hc)
                ne      = get_now()
                if debug:print fun,'get html in %s s on access' % str(ne - ns)
Ejemplo n.º 2
0
 def get_hc_normal(self,url):
     ''' 不以登录状态获取mouser页面 '''
     fun     = 'function get_hc_normal'
     ns          = get_now()
     
     try:
         ''' 下面两句: 前句为默认的语句;  后句为修改后 加上pangtong访问代理前缀  edit by daimingming 2013年 01月 07日 星期一 15:04:30 CST '''
         req         = liulanqi.Request(url)#test
         #req         = liulanqi.Request(get_pangtong_proxy_url(url))#test
         req_open    = liulanqi.urlopen(req)
         hc          = req_open.read()
         info_url    = req_open.geturl()
     except Exception,e:
         hc          = 'timeout'
         info_url    = url
Ejemplo n.º 3
0
        fun     = 'function get_hc_normal'
        ns          = get_now()
        
        try:
            ''' 下面两句: 前句为默认的语句;  后句为修改后 加上pangtong访问代理前缀  edit by daimingming 2013年 01月 07日 星期一 15:04:30 CST '''
            req         = liulanqi.Request(url)#test
            #req         = liulanqi.Request(get_pangtong_proxy_url(url))#test
            req_open    = liulanqi.urlopen(req)
            hc          = req_open.read()
            info_url    = req_open.geturl()
        except Exception,e:
            hc          = 'timeout'
            info_url    = url
        ''' 获取此时真实的url响应url '''
        hc          = '<info_url>%s</info_url>' % str(info_url) + str(hc)
        ne          = get_now()
        
        if debug:print fun,'get html in %s s on access' % str(ne - ns)
        return hc

if __name__ == '__main__':
    s = """
        登录类的两种用法:
        1 loginmouser = LoginMouser() 该方法获取的代码可能是英文 也可能是中文 不能够持续稳定
        2 loginmouser = LoginMouser(language='chinese/english') 或者 LoginMouser(**{'language':'chinese/english'})
        """
    print s

    #xz = get_xz('enter your language: 1 '' 2 english 3 chinese? ',['','english','chinese'])
    #xz = 'english'
    xz = 'chinese'