-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
executable file
·33 lines (28 loc) · 1.03 KB
/
main.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
import time
import sys
from crawler import Crawler
from crawler import CosineSimilarity as cs
from assets import Global
from connectKafka import cons,prod
def main():
if len(sys.argv)<2:
print("默認 爬資料")
cs.makeCsv()
while 1:
Crawler.get_articles(Global.YAHOO_URL_POLITICS,"politics")
Crawler.get_articles(Global.YAHOO_URL_ENTERTAINMENT,"entertainment")
print("\n本次資料已取完!\n")
time.sleep(10800) # 3 hours
else:
if sys.argv[1].upper().strip() == "CONSUMER":
cons.Print("politics")
cons.Print("entertainment")
elif sys.argv[1].upper().strip() == "REQUEST":
cs.makeCsv()
while 1:
Crawler.get_articles(Global.YAHOO_URL_POLITICS,"politics")
Crawler.get_articles(Global.YAHOO_URL_ENTERTAINMENT,"entertainment")
print("\n本次資料已取完!\n")
time.sleep(10800) # 3 hours
if __name__ == '__main__':
main()