소스 검색

Merge branch 'master' of https://git.fop.pe/Foppe/scratchings

Afwas [1337627 6 년 전
부모
커밋
3f1ab9f35d
3개의 변경된 파일13개의 추가작업 그리고 5개의 파일을 삭제
  1. 6 2
      _bs.py
  2. 5 1
      main.py
  3. 2 2
      model.py

+ 6 - 2
_bs.py

@@ -22,19 +22,23 @@ RaceDay = collections.namedtuple('RaceDay', RaceDayShort._fields + (
 Scratching = collections.namedtuple('Scratching', 'venue date race horse')
 
 
-def get_today_row(this_text):
+def get_today_row(this_text, this_row):
     """
     Traverses the main table on the front page of https://racingaustralia.horse.
     This function scrapes Venue information and race day information.
     Unfortunately there is no clever way to split this function into two parts.
     :param this_text:
+    :param this_row:
     :return RaceDay this_race_day:
     """
     this_soup = BeautifulSoup(this_text, 'html.parser')
     rows = this_soup.select('tr.rows')
     # print('len(rows) {}'.format(len(rows)))
     all_race_days = []
-    for day in range(len(rows)):
+    days_to_check = [this_row]
+    if this_row == 0:
+        days_to_check = range(len(rows))
+    for day in days_to_check:
         my_row = rows[day]
         cells = my_row.select('td')
         i = 0

+ 5 - 1
main.py

@@ -3,13 +3,17 @@ import model
 from pprint import pprint
 import time
 import database
+import sys
 
 if __name__ == '__main__':
+    row = 0
+    if len(sys.argv) > 1:
+        row = sys.argv[1]
     start = time.time()
 
     db = database.db
 
-    race_days_global = model.scrape_main_page()
+    race_days_global = model.scrape_main_page(row)
     interim = time.time()
     print('interim 1 {}'.format(interim - start))
     # pprint(race_days_global)

+ 2 - 2
model.py

@@ -21,10 +21,10 @@ local_timezones = {
     "NT": "Australia/Darwin"}
 
 
-def scrape_main_page():
+def scrape_main_page(row):
     this_url = """https://racingaustralia.horse/Home.aspx"""
     this_data = _html.get_page(this_url)
-    venues_all = _bs.get_today_row(this_data)
+    venues_all = _bs.get_today_row(this_data, row)
     return venues_all