Example #1
0
def searchpage(keyword,pagenum):
    cookies = request.cookies
    cookiestr = ''
    for i in cookies:
        cookiestr = cookiestr + i + '=' + cookies[i] + ';' + ' '  
    headerlist,htmlcontent = handle2.dopage(pagenum,handle2.getdecodecookiestr(cookiestr))
    contentlist = parsehtml2.makecontentlist(htmlcontent)
    contentlistex = []
    for l in contentlist:
        l['link'] = parsehtml2.getlinkstr(l)
        contentlistex.append(l)
    pagemap = parsehtml2.makelinkmap(keyword,int(pagenum))
    resp = make_response(render_template('search.html',keyword=keyword,contentlist=contentlistex,linkmap=pagemap),200,headerlist)
    return resp
Example #2
0
                except Exception,e:
                        doerror(start_response)
                        return
                resulthtml = parsehtml2.makeresulthtml(htmlcontent,page=int(querys['p']))
#		contentlist = parsehtml2.makecontentlist(htmlcontent)
#		contentstr = ''
#		for line in contentlist:
#			contentstr = contentstr + line['title'].encode('utf-8')+'&nbsp;'+line['author'].encode('utf-8') + '<br>'
                if len(resulthtml) != 5:
                        write = start_response('200 OK',headerlist + [('Content-Length',str(len(resulthtml)))])
                        write(resulthtml)
                else:
                        doerror(start_response)
                        return
        else:
                doerror(start_response)
                return

if __name__=='__main__':
        print 'start'
        cookies = gethandleheader('java')
        cookiestr = ''
        for line in cookies:
                if not line[0].find('Set-Cookie')<0:
                        cookiestr = cookiestr + ' ' + str(line[1]).split(';')[0] + ';'
        print cookiestr
        htmlcontent = getsearchcontent('java',cookiestr)
        print htmlcontent
        contentlist = parsehtml2.makecontentlist(htmlcontent)
        print contentlist
        print 'finished'