Example #1
0
 def search_from_database(self, number):
     thread_list = []
     q1 = DB_Query()
     q2 = DB_Query()
     q3 = DB_Query()
     q4 = DB_Query()
     q5 = DB_Query()
     #余额查询
     t1 = MyThread(q1.balance_query, args=(number, ))
     #通信消费查询
     t2 = MyThread(q2.expenses_query, args=(number, ))
     #发展渠道
     t3 = MyThread(q3.develop_type_query, args=(number, ))
     #充值查询
     t4 = MyThread(q4.deposit_query, args=(number, ))
     #年龄查询
     t5 = MyThread(q5.age_query, args=(number, ))
     thread_list = [t1, t2, t3, t4, t5]
     for t in thread_list:
         t.start()
     for t in thread_list:
         t.join()
     balance = t1.get_result()
     fee, sms_count, flow_data, call_duration = t2.get_result()
     develop_type = t3.get_result()
     last_deposit_fee, deposit_interval_day = t4.get_result()
     age = t5.get_result()
     return [
         balance, fee, sms_count, flow_data, call_duration, develop_type,
         last_deposit_fee, age, deposit_interval_day
     ]
Example #2
0
def get_baiduzd_faq(question):
	answers = []															# 返回值
	question_list_html = None							# 返回百度知道搜索结果的第一页 html 文本
	while question_list_html is None:
		question_list_html = get_baiduzd_page(question)							# 返回百度知道搜索结果的第一页 html 文本

	if(question_list_html is None):
		print("爬取百度知道答案列表页面失败!")
		return None
	questions = get_sim_questions(question_list_html)						# questions 为 问题句子-链接 字典
	threadPool = []															# 线程队列
	for question in questions:												# 遍历每个问题链接,获取该问题的前 5 个答案
		thread = MyThread(get_a_question_ans,args=(question['link']))		# 多线程加速
		thread.start()
		threadPool.append(thread)

	for thread in threadPool:
		thread.join()

	for thread in threadPool:
		res = thread.get_result()
		if res is not None:
			answers += res

	return answers