Пример #1
0
def search(request):
    global amazonlist
    global dangdanglist
    global yhdlist
    global taobaolist
    amazonlist = []
    dangdanglist = []
    yhdlist = []
    taobaolist = []
    threads = []
    keyword = request.GET.get("search", "")
    types = request.GET.get("filter", "")
    if types == "all":
        amazon_t = AmazonThread(keyword)
        dangdang_t = DangdangThread(keyword)
        yhd_t = YhdThread(keyword)
        taobao_t = TaobaoThread(keyword)
        threads.append(amazon_t)
        threads.append(dangdang_t)
        threads.append(yhd_t)
        threads.append(taobao_t)
        for thread in threads:
            thread.start()
        for thread in threads:
            thread.join()
    elif types == "amazon":
        amazonlist = spider.amazon(keyword)
    elif types == "dangdang":
        dangdanglist = spider.dangdang(keyword)
    elif types == "yhd":
        yhdlist = spider.yhd(keyword)
    else:
        taobaolist = spider.taobao(keyword)

    return render_to_response('result.html',{'amazonlist':amazonlist, 'dangdanglist':dangdanglist, \
           'yhdlist':yhdlist, 'taobaolist':taobaolist, 'user':request.user})
Пример #2
0
 def run (self):
     global yhdlist
     yhdlist = spider.yhd(self.keyword)