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})
def run (self): global amazonlist amazonlist = spider.amazon(self.keyword)