Example #1
0
def test_case_a(data,c):
    keywordvlue = "destination"
    #keywordvlue = "CompanyList"
    #keywordvlue = "FeatureList"
    table = data.sheet_by_name('url')
    urlhttp = table.cell(1, read_excel.find_colum(file,'url','url')).value+"action=autocomplete&source=globalapp64&lon=121.35801673&lat=31.22016018&districtid=2"+"&keyword="+keyword
    for row_date in range(1, read_excel.rownum(file,'insurance')):
        table = data.sheet_by_name('insurance')
        bb = table.cell(row_date, read_excel.find_colum(file,'insurance',keywordvlue)).value
        reload(sys)
        sys.setdefaultencoding('utf-8')
        bb = str(bb)
        aa = urllib.quote(bb)
        urldate = urlhttp+aa+urllib.quote("保险")
        lennum = http.lendate(urldate)
        errcode = http.head(urldate,"errcode")
        word = http.get_key_vlue(urldate,0,"word")
        type = http.get_key_vlue(urldate,0,"type")
        urlt = http.get_key_vlue(urldate,0,"url")
        count = urlt.count(keywordvlue)
        #print lennum,word,bb+"保险",errcode,type,count
        if lennum == 1 and word == bb+"保险" and errcode ==0 and type == "insurance" and count==1:
            print word,urlt
            #print urldate
        else:
            print word,urlt
Example #2
0
def start():
    row_date = 1
    andf = 1
    fromt = 1
    andm = 1
    tot =1
    bb = ''

    file = 'D:\work\code\ctriptest\datebase1.xls'
    data = read_excel.open_excel(file)
    table = data.sheet_by_name('type')
    typelist = []
    for row_date in range(1, read_excel.rownum(file,'type')):
        bb = table.cell(row_date, read_excel.find_colum(file,'type','keyword')).value
        #bb = 'shanghai'
        reload(sys)
        sys.setdefaultencoding('utf-8')
        bb = str(bb)
        #time.sleep(2)
        aa = urllib.quote(bb)
        url = 'http://10.2.25.24:8180/appautocomplete/search?keyword='+aa+'&action=autocomplete&source=globalapp63&lon=121.35801673&lat=31.22016018&districtid=2'
        lennum = http.lendate(url)
        num = 0
        for num in range(lennum):
            #print http.get_key_vlue(url,num,"type")
            if http.get_key_vlue(url,num,"type") not in typelist:
                typelist.append(http.get_key_vlue(url,num,"type"))
                print http.get_key_vlue(url,num,"word"), http.get_key_vlue(url,num,"type")