-
Notifications
You must be signed in to change notification settings - Fork 1
/
auto.py
55 lines (43 loc) · 1.52 KB
/
auto.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
import string
import os
from twisted.internet import reactor
from scrapy.crawler import Crawler
# from horses2.spiders import Horses2xspider
from scrapy import log, signals
from scrapy.utils.project import get_project_settings
#this line is dangerous for impport statements elsewhere!
# from spiders.horses2 import Horses2xspider
#get this meetings codes
letters = string.ascii_uppercase
# newletters = letters.replace('ABCDEFGHIJKL', '')
newletters = ['S']
digits = string.digits
#better option would be to get today's horsecodes
def gettodayshorsecodes(racedate):
pass
def main():
for l in newletters:
horsecodes = []
counter = 0;
numcode = '001'
while numcode < '999':
numcode = format(counter, '03')
horsecodes.append(l + numcode)
counter +=1
runscrapy(horsecodes)
# os.system("scrapy crawl horses2x -a horse='P222'")
def runscrapy(horsecodes):
'''takes a list of horsecodes, runs scrapy, keeps track of urls which do not hit'''
# misses = {}
# config init
horsecodes= ",".join(horsecodes)
# print horsecodes
# os.system("scrapy crawl horses2x -a horse='P222'")
os.system("curl http://localhost:6802/schedule.json -d project=horsesx -d spider=horses2x -d setting=DOWNLOAD_DELAY=2 -d horses=" + horsecodes + "")
os.system("curl http://localhost:6802/schedule.json -d project=horsesx -d spider=vet -d setting=DOWNLOAD_DELAY=2 -d horses=" + horsecodes + "")
# os.system("scrapy crawl horses2x -a horses=" + horsecodes)
#use scrapyd
#run trackwork spider
if __name__ == "__main__":
main()
#run vet spider