|
10 | 10 | import time
|
11 | 11 | import datetime
|
12 | 12 | from client import RestClient
|
| 13 | +import json |
13 | 14 |
|
14 | 15 |
|
15 | 16 | if __name__ == '__main__':
|
|
28 | 29 | password = conf['general']['password']
|
29 | 30 |
|
30 | 31 | # Output headers
|
31 |
| - fields=['task_id','status','request','request_type','domain','location_code','language_code','timestamp','results_count','rank_group','rank_absolute','result_type','title','description','url','breadcrumb'] |
| 32 | + fields=['task_id','status','request','request_type','domain','location_code','language_code','timestamp','results_count','spell','item_types','rank_group','rank_absolute','item_type','title','description','url','breadcrumb'] |
32 | 33 | # Output name
|
33 | 34 | timestr = time.strftime("%Y%m%d-%H%M%S")
|
34 | 35 | tag = args.output + "-" + timestr
|
|
58 | 59 | results.append(client.get(resultTaskInfo['endpoint_regular']))
|
59 | 60 |
|
60 | 61 | for result in results:
|
| 62 | + print(result) |
| 63 | + |
61 | 64 | for task in result["tasks"]:
|
62 | 65 | task_id = task['id']
|
63 | 66 | status = task['status_message']
|
|
69 | 72 | language_code = kw["language_code"]
|
70 | 73 | timestamp = kw["datetime"]
|
71 | 74 | results_count = kw["se_results_count"]
|
| 75 | + spell = json.dumps(kw["spell"]) |
| 76 | + item_types = json.dumps(kw["item_types"]) |
72 | 77 |
|
73 | 78 | for item in kw["items"]:
|
74 | 79 | row = dict()
|
|
80 | 85 | row["location_code"] = location_code
|
81 | 86 | row["language_code"] = language_code
|
82 | 87 | row["timestamp"] = timestamp
|
| 88 | + row["spell"] = spell |
| 89 | + row["item_types"] = item_types |
83 | 90 | row["results_count"] = results_count
|
84 |
| - row["result_type"] = item["type"] |
| 91 | + row["item_type"] = item["type"] |
85 | 92 | row["rank_group"] = item["rank_group"]
|
86 | 93 | row["rank_absolute"] = item["rank_absolute"]
|
87 | 94 | row["title"] = item["title"]
|
|
93 | 100 | writer = csv.DictWriter(file, fieldnames=fields, delimiter=";")
|
94 | 101 | writer.writerow(row)
|
95 | 102 | file.close()
|
| 103 | + exit(0) |
96 | 104 |
|
97 | 105 | print("Batch done.")
|
98 | 106 | time.sleep(args.delay)
|
|
0 commit comments