-
Notifications
You must be signed in to change notification settings - Fork 53
/
findcompany.py
62 lines (36 loc) · 1.09 KB
/
findcompany.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env python
# -*- coding: utf-8 -*-
""" find best return rate company """
__author__ = 'ggstar'
import spider
import time
import lottery
match_all_ids = []
for day in range(13, 20, 1):
match_ids = spider.crawl_match_list_by_date("2014-07-" + str(day))
match_all_ids += match_ids
item_list = []
seq = 0
company_map = {}
for match_id in match_all_ids:
seq += 1
print seq, match_id
match = spider.get_match(match_id)
for item in match.item_arr:
if item.company in company_map:
cur_company = company_map[item.company]
cur_company.back_ratio = \
(cur_company.back_ratio * cur_company.count + item.back_ratio) / \
(cur_company.count + 1)
cur_company.count += 1
else:
company_map[item.company] = item
time.sleep(5)
companies = []
for company in company_map.values():
companies.append(company)
companies.sort(lambda x, y: cmp(x.back_ratio, y.back_ratio))
seq = 0
for company in companies:
seq += 1
print seq, company.id, company.company, company.back_ratio