update,
This commit is contained in:
Binary file not shown.
After Width: | Height: | Size: 65 KiB |
75
abc2022d/task1/ticket0002/Common.bas
Normal file
75
abc2022d/task1/ticket0002/Common.bas
Normal file
@@ -0,0 +1,75 @@
|
||||
Attribute VB_Name = "Common"
|
||||
|
||||
Option Explicit
|
||||
|
||||
Global CURRENT_DIR As String
|
||||
|
||||
Function getDateFrRaceCardLink(ByVal in_str As String)
|
||||
' https://racing.hkjc.com/racing/information/English/Racing/Racecard.aspx?RaceDate=2024/04/24&Racecourse=HV&RaceNo=2
|
||||
Dim s_date, s_loc, s_race_num As String
|
||||
s_date = Split(Split(in_str, "=")(1), "&")(0)
|
||||
s_loc = Split(Split(in_str, "=")(2), "&")(0)
|
||||
s_race_num = Split(in_str, "=")(3)
|
||||
|
||||
getDateFrRaceCardLink = Array(s_date, s_loc, s_race_num)
|
||||
End Function
|
||||
|
||||
Function readCell(cell_address As String)
|
||||
Dim temp As String
|
||||
temp = Worksheets("Sheet1").Range(cell_address).value
|
||||
readCell = temp
|
||||
End Function
|
||||
|
||||
Function writeCell(cell_address As String, content As String)
|
||||
'write cell according to cell_address and content
|
||||
Worksheets("Sheet1").Range(cell_address).value = content
|
||||
|
||||
writeCell = content
|
||||
End Function
|
||||
|
||||
|
||||
Function ResetSheet()
|
||||
Worksheets("Sheet1").Range("A3:AC200").ClearContents
|
||||
End Function
|
||||
|
||||
|
||||
Function TidySheet()
|
||||
Worksheets("Sheet1").Range("OK1:OK200").ClearContents
|
||||
|
||||
'widen column width
|
||||
Worksheets("Sheet1").Range("A2:DF200").Columns.AutoFit
|
||||
|
||||
' align text to center
|
||||
Worksheets("Sheet1").Range("A2:DF200").HorizontalAlignment = xlCenter
|
||||
|
||||
End Function
|
||||
|
||||
|
||||
Function ParseDDMMYYYY(input_string As String)
|
||||
Dim s_day As String
|
||||
Dim s_month As String
|
||||
Dim s_year As String
|
||||
|
||||
s_day = Split(input_string, "/")(0)
|
||||
s_month = Split(input_string, "/")(1)
|
||||
s_year = Split(input_string, "/")(2)
|
||||
|
||||
ParseDDMMYYYY = DateSerial(CInt(s_year), CInt(s_month), CInt(s_day))
|
||||
End Function
|
||||
|
||||
Sub DisableScreenUpdate
|
||||
Application.ScreenUpdating = False 'disable screen updating
|
||||
Application.Calculation = xlCalculationManual 'disable automatic calculation
|
||||
Application.EnableEvents = False 'disable event handling
|
||||
Application.DisplayAlerts = False 'disable alerts
|
||||
|
||||
end sub
|
||||
|
||||
|
||||
sub ResumeScreenUpdate
|
||||
Application.ScreenUpdating = True 'enable screen updating
|
||||
Application.Calculation = xlCalculationAutomatic 'enable automatic calculation
|
||||
Application.EnableEvents = True 'enable event handling
|
||||
Application.DisplayAlerts = True 'enable alerts
|
||||
|
||||
end sub
|
163
abc2022d/task1/ticket0002/DisplaySectionalTime_aspx.bas
Normal file
163
abc2022d/task1/ticket0002/DisplaySectionalTime_aspx.bas
Normal file
@@ -0,0 +1,163 @@
|
||||
Attribute VB_Name = "DisplaySectionalTime_aspx"
|
||||
|
||||
Option Explicit
|
||||
|
||||
|
||||
Public Function ScrapeDisplaySectionalTime(driver As WebDriver, ByVal race_date As String, race_num As String, row_offset As Integer, ByVal horse_count As Integer)
|
||||
Dim COL_IDX_HORSE_NO As Integer
|
||||
Dim COL_IDX_LAST_6_RUNS As Integer
|
||||
Dim COL_IDX_COLOUR As Integer
|
||||
Dim COL_IDX_HORSE As Integer
|
||||
Dim COL_IDX_BRAND_NO As Integer
|
||||
Dim COL_IDX_WT As Integer
|
||||
Dim COL_IDX_JOCKEY As Integer
|
||||
Dim COL_IDX_OVER_WT As Integer
|
||||
Dim COL_IDX_DRAW As Integer
|
||||
Dim COL_IDX_TRAINER As Integer
|
||||
Dim COL_IDX_RTG As Integer
|
||||
Dim COL_IDX_RTG_PLUS_MINUS As Integer
|
||||
Dim COL_IDX_HORSE_WT_DECLARATION As Integer
|
||||
Dim COL_IDX_WT_PLUS_MINUS_VS_DECLARATION As Integer
|
||||
Dim COL_IDX_BEST_TIME As Integer
|
||||
Dim COL_IDX_AGE As Integer
|
||||
Dim COL_IDX_WFA As Integer
|
||||
Dim COL_IDX_SEX As Integer
|
||||
Dim COL_IDX_SEASON_STAKES As Integer
|
||||
Dim COL_IDX_PRIORITY As Integer
|
||||
Dim COL_IDX_DAYS_SINCE_LAST_RUN As Integer
|
||||
Dim COL_IDX_GEAR As Integer
|
||||
Dim COL_IDX_OWNER As Integer
|
||||
Dim COL_IDX_SIRE As Integer
|
||||
Dim COL_IDX_DAM As Integer
|
||||
Dim COL_IDX_IMPORT_CAT As Integer
|
||||
|
||||
Dim script_content, script_result As String
|
||||
|
||||
Dim i, j As Integer
|
||||
|
||||
|
||||
On Error GoTo ErrorHandler
|
||||
|
||||
' Navigate to a website.
|
||||
Dim s_year, s_month, s_date, temp_new_date As String
|
||||
s_year = Split(race_date, "/")(0)
|
||||
s_month = Split(race_date, "/")(1)
|
||||
s_date = Split(race_date, "/")(2)
|
||||
temp_new_date = s_date & "/" & s_month & "/" & s_year
|
||||
Dim s_race_date As String
|
||||
s_race_date = Format(temp_new_date, "DD/MM/YYYY")
|
||||
|
||||
driver.Get "https://racing.hkjc.com/racing/information/chinese/Racing/DisplaySectionalTime.aspx?RaceDate=" & s_race_date & "&RaceNo=" & race_num
|
||||
|
||||
|
||||
Dim startCell As Range
|
||||
Set startCell = Worksheets("Sheet1").Range("A3")
|
||||
|
||||
|
||||
|
||||
' test if match result table found
|
||||
Dim table_count, table_count_result As String
|
||||
table_count_result = driver.ExecuteScript("{ return document?.querySelectorAll('.Race').length }")
|
||||
table_count = CInt(table_count_result)
|
||||
|
||||
|
||||
If (table_count > 0) Then
|
||||
|
||||
|
||||
|
||||
Dim hourse_table As Variant
|
||||
script_content = "{" & _
|
||||
" list_e = [];" & _
|
||||
" document" & _
|
||||
" .querySelector('table.race_table')" & _
|
||||
" .querySelectorAll('tr')" & _
|
||||
" .forEach((e_tr, idx) => {" & _
|
||||
" if (idx > 2) {" & _
|
||||
" list_td = [];" & _
|
||||
" temp = e_tr.querySelectorAll('td');" & _
|
||||
" list_td.push(temp[2].textContent.replace(/[\(\)]/g,'').split(/\s/g)[1]);" & _
|
||||
" list_td.push(temp[3]?.querySelectorAll('p')[1]?.textContent.replace(/\n/g, '')?.split(/\s+/g)[0] || '-');" & _
|
||||
" list_td.push(temp[4]?.querySelectorAll('p')[1]?.textContent.replace(/\n/g, '')?.split(/\s+/g)[0] || '-');" & _
|
||||
" list_td.push(temp[5]?.querySelectorAll('p')[1]?.textContent.replace(/\n/g, '')?.split(/\s+/g)[0] || '-');" & _
|
||||
" list_td.push(temp[6]?.querySelectorAll('p')[1]?.textContent.replace(/\n/g, '')?.split(/\s+/g)[0] || '-');" & _
|
||||
" list_td.push(temp[7]?.querySelectorAll('p')[1]?.textContent.replace(/\n/g, '')?.split(/\s+/g)[0] || '-');" & _
|
||||
" list_td.push(temp[8]?.querySelectorAll('p')[1]?.textContent.replace(/\n/g, '')?.split(/\s+/g)[0] || '-');" & _
|
||||
" list_td.push(temp[9]?.textContent);" & _
|
||||
" list_e.push(list_td.join(','));" & _
|
||||
" }" & _
|
||||
" });" & _
|
||||
" return list_e.join('|||'); " & _
|
||||
"}"
|
||||
script_result = driver.ExecuteScript(script_content)
|
||||
hourse_table = Split(script_result, "|||")
|
||||
|
||||
'Country of origin
|
||||
' document.querySelector('table.race_table').querySelectorAll('tr')[2+1].querySelectorAll('td')[0-9]
|
||||
For i = LBound(hourse_table) To UBound(hourse_table)
|
||||
For j = LBound(hourse_table) To UBound(hourse_table)
|
||||
Dim temp As Variant
|
||||
temp = Split(hourse_table(j), ",")
|
||||
Dim horse_id As String
|
||||
|
||||
|
||||
If (InStr(startCell.Offset(row_offset + i, 37).value, temp(0)) > 0) Then
|
||||
startCell.Offset(row_offset + i, 51 + 0).value = temp(1)
|
||||
startCell.Offset(row_offset + i, 51 + 1).value = temp(2)
|
||||
startCell.Offset(row_offset + i, 51 + 2).value = temp(3)
|
||||
startCell.Offset(row_offset + i, 51 + 3).value = temp(4)
|
||||
startCell.Offset(row_offset + i, 51 + 4).value = temp(5)
|
||||
startCell.Offset(row_offset + i, 51 + 5).value = temp(6)
|
||||
startCell.Offset(row_offset + i, 51 + 6).value = "'" & temp(7)
|
||||
End If
|
||||
Next j
|
||||
Next i
|
||||
|
||||
|
||||
Else
|
||||
For j = 0 To horse_count - 1
|
||||
' table not ready yet
|
||||
startCell.Offset(row_offset + j, 30).value = "HKJC table not ready"
|
||||
Next j
|
||||
|
||||
End If
|
||||
|
||||
GoTo Done
|
||||
|
||||
ErrorHandler:
|
||||
MsgBox "hello error ?"
|
||||
MsgBox "Error: " & Err.Description
|
||||
|
||||
Done:
|
||||
Debug.Print "hello done"
|
||||
|
||||
|
||||
End Function
|
||||
|
||||
|
||||
|
||||
' write cell
|
||||
Sub writeCell(cell_addres As String, value As String)
|
||||
|
||||
End Sub
|
||||
|
||||
|
||||
Private Sub Take_ScreenShot_Desktop()
|
||||
Dim utils As New utils
|
||||
Dim driver As New ChromeDriver
|
||||
driver.Get "https://en.wikipedia.org/wiki/Main_Page"
|
||||
|
||||
Dim img As Object
|
||||
|
||||
'take a screenshot of the desktop
|
||||
Set img = utils.TakeScreenshot()
|
||||
|
||||
'save the image in the folder of the workbook
|
||||
img.SaveAs ThisWorkbook.Path & "\sc-desktop.png"
|
||||
|
||||
driver.Quit
|
||||
End Sub
|
||||
|
||||
|
||||
|
||||
|
||||
|
5
abc2022d/task1/ticket0002/Helloworld.bas
Normal file
5
abc2022d/task1/ticket0002/Helloworld.bas
Normal file
@@ -0,0 +1,5 @@
|
||||
Attribute VB_Name = "Helloworld"
|
||||
Sub TestHelloworld()
|
||||
|
||||
|
||||
End Sub
|
87
abc2022d/task1/ticket0002/Horse_aspx.bas
Normal file
87
abc2022d/task1/ticket0002/Horse_aspx.bas
Normal file
@@ -0,0 +1,87 @@
|
||||
Attribute VB_Name = "Horse_aspx"
|
||||
|
||||
Option Explicit
|
||||
|
||||
|
||||
Public Function ScrapeHorse(driver As WebDriver, horse_id As String, row_offset As String)
|
||||
Dim COL_IDX_HORSE_NO As Integer
|
||||
Dim COL_IDX_LAST_6_RUNS As Integer
|
||||
Dim COL_IDX_COLOUR As Integer
|
||||
Dim COL_IDX_HORSE As Integer
|
||||
Dim COL_IDX_BRAND_NO As Integer
|
||||
Dim COL_IDX_WT As Integer
|
||||
Dim COL_IDX_JOCKEY As Integer
|
||||
Dim COL_IDX_OVER_WT As Integer
|
||||
Dim COL_IDX_DRAW As Integer
|
||||
Dim COL_IDX_TRAINER As Integer
|
||||
Dim COL_IDX_RTG As Integer
|
||||
Dim COL_IDX_RTG_PLUS_MINUS As Integer
|
||||
Dim COL_IDX_HORSE_WT_DECLARATION As Integer
|
||||
Dim COL_IDX_WT_PLUS_MINUS_VS_DECLARATION As Integer
|
||||
Dim COL_IDX_BEST_TIME As Integer
|
||||
Dim COL_IDX_AGE As Integer
|
||||
Dim COL_IDX_WFA As Integer
|
||||
Dim COL_IDX_SEX As Integer
|
||||
Dim COL_IDX_SEASON_STAKES As Integer
|
||||
Dim COL_IDX_PRIORITY As Integer
|
||||
Dim COL_IDX_DAYS_SINCE_LAST_RUN As Integer
|
||||
Dim COL_IDX_GEAR As Integer
|
||||
Dim COL_IDX_OWNER As Integer
|
||||
Dim COL_IDX_SIRE As Integer
|
||||
Dim COL_IDX_DAM As Integer
|
||||
Dim COL_IDX_IMPORT_CAT As Integer
|
||||
|
||||
Dim script_content As String
|
||||
|
||||
' ' Create a new instance of the WebDriver.
|
||||
' Dim driver As New WebDriver
|
||||
|
||||
' ' Set the path to the WebDriver executable.
|
||||
' driver.SetBinary "C:\Users\logic\AppData\Local\Chromium\Application\chrome.exe"
|
||||
|
||||
' ' Start Chrome.
|
||||
' driver.Start "chrome"
|
||||
|
||||
' Navigate to a website.
|
||||
driver.Get "https://racing.hkjc.com/racing/information/Chinese/Horse/Horse.aspx?HorseId=" & horse_id
|
||||
|
||||
' document.querySelectorAll('#racecardlist tbody tr')[2].textContent
|
||||
Dim i, j As Integer
|
||||
|
||||
|
||||
Dim startCell As Range
|
||||
Set startCell = Worksheets("Sheet1").Range("A3")
|
||||
|
||||
|
||||
'Country of origin
|
||||
' document.querySelector('table.horseProfile').querySelectorAll('td')[6].querySelectorAll('td')[2]
|
||||
script_content = "{ return document.querySelector('table.horseProfile').querySelectorAll('td')[6].querySelectorAll('td')[2].textContent.trim().split('/')[0].trim() }"
|
||||
startCell.Offset(row_offset, 28).value = driver.ExecuteScript(script_content)
|
||||
|
||||
'import type
|
||||
' document.querySelector('table.horseProfile').querySelectorAll('td')[6].querySelectorAll('td')[8]
|
||||
script_content = "{ return document.querySelector('table.horseProfile').querySelectorAll('td')[6].querySelectorAll('td')[8].textContent.trim() }"
|
||||
|
||||
End Function
|
||||
|
||||
|
||||
|
||||
Private Sub Take_ScreenShot_Desktop()
|
||||
Dim utils As New utils
|
||||
Dim driver As New ChromeDriver
|
||||
driver.Get "https://en.wikipedia.org/wiki/Main_Page"
|
||||
|
||||
Dim img As Object
|
||||
|
||||
'take a screenshot of the desktop
|
||||
Set img = utils.TakeScreenshot()
|
||||
|
||||
'save the image in the folder of the workbook
|
||||
img.SaveAs ThisWorkbook.Path & "\sc-desktop.png"
|
||||
|
||||
driver.Quit
|
||||
End Sub
|
||||
|
||||
|
||||
|
||||
|
243
abc2022d/task1/ticket0002/LocalResults_aspx.bas
Normal file
243
abc2022d/task1/ticket0002/LocalResults_aspx.bas
Normal file
@@ -0,0 +1,243 @@
|
||||
Attribute VB_Name = "LocalResults_aspx"
|
||||
|
||||
Option Explicit
|
||||
|
||||
|
||||
Public Sub ScrapeLocalResults()
|
||||
Dim COL_IDX_HORSE_NO As Integer
|
||||
Dim COL_IDX_LAST_6_RUNS As Integer
|
||||
Dim COL_IDX_COLOUR As Integer
|
||||
Dim COL_IDX_HORSE As Integer
|
||||
Dim COL_IDX_BRAND_NO As Integer
|
||||
Dim COL_IDX_WT As Integer
|
||||
Dim COL_IDX_JOCKEY As Integer
|
||||
Dim COL_IDX_OVER_WT As Integer
|
||||
Dim COL_IDX_DRAW As Integer
|
||||
Dim COL_IDX_TRAINER As Integer
|
||||
Dim COL_IDX_RTG As Integer
|
||||
Dim COL_IDX_RTG_PLUS_MINUS As Integer
|
||||
Dim COL_IDX_HORSE_WT_DECLARATION As Integer
|
||||
Dim COL_IDX_WT_PLUS_MINUS_VS_DECLARATION As Integer
|
||||
Dim COL_IDX_BEST_TIME As Integer
|
||||
Dim COL_IDX_AGE As Integer
|
||||
Dim COL_IDX_WFA As Integer
|
||||
Dim COL_IDX_SEX As Integer
|
||||
Dim COL_IDX_SEASON_STAKES As Integer
|
||||
Dim COL_IDX_PRIORITY As Integer
|
||||
Dim COL_IDX_DAYS_SINCE_LAST_RUN As Integer
|
||||
Dim COL_IDX_GEAR As Integer
|
||||
Dim COL_IDX_OWNER As Integer
|
||||
Dim COL_IDX_SIRE As Integer
|
||||
Dim COL_IDX_DAM As Integer
|
||||
Dim COL_IDX_IMPORT_CAT As Integer
|
||||
|
||||
Dim not_used As Variant
|
||||
|
||||
On Error GoTo ErrorHandler
|
||||
ResetCell
|
||||
|
||||
Dim race_date As String
|
||||
Dim s_year, s_month, s_date, temp_new_date As String
|
||||
race_date = Common.readCell("AE1")
|
||||
|
||||
s_year = Split(race_date, "/")(0)
|
||||
s_month = Split(race_date, "/")(1)
|
||||
s_date = Split(race_date, "/")(2)
|
||||
temp_new_date = s_date & "/" & s_month & "/" & s_year
|
||||
|
||||
Dim s_race_date As String
|
||||
s_race_date = Format(temp_new_date, "DD/MM/YYYY")
|
||||
|
||||
|
||||
'ByVal race_date As String, race_num As String, row_offset As Integer, horse_count As Integer
|
||||
Dim row_offset As Integer
|
||||
row_offset = 0
|
||||
|
||||
' on error goto eh
|
||||
On Error GoTo ErrorHandler
|
||||
|
||||
' Create a new instance of the WebDriver.
|
||||
Dim driver As New WebDriver
|
||||
|
||||
' Set the path to the WebDriver executable.
|
||||
|
||||
Dim CURRENT_DIR As String
|
||||
CURRENT_DIR = ThisWorkbook.Path
|
||||
driver.SetBinary CURRENT_DIR & "\Chromium\Application\chrome.exe"
|
||||
driver.AddArgument "--disable-blink-features=AutomationControlled --blink-settings=imagesEnabled=false"
|
||||
|
||||
' Start Chrome.
|
||||
driver.Start "chrome"
|
||||
|
||||
|
||||
Dim By As New By
|
||||
' Navigate to a website.
|
||||
' https://racing.hkjc.com/racing/information/Chinese/Racing/LocalResults.aspx?RaceDate=2024/04/20&Racecourse=ST&RaceNo=1
|
||||
driver.Get "https://racing.hkjc.com/racing/information/Chinese/Racing/LocalResults.aspx?RaceDate=" & s_race_date & "&RaceNo=1"
|
||||
|
||||
' document.querySelectorAll('#racecardlist tbody tr')[2].textContent
|
||||
|
||||
Dim startCell As Range
|
||||
Set startCell = Worksheets("Sheet1").Range("A3")
|
||||
|
||||
Dim hourse_number As String
|
||||
Dim script_content, script_result As String
|
||||
Dim hourse_table As Variant
|
||||
|
||||
|
||||
' test if match result table found
|
||||
Dim table_count, table_count_result As String
|
||||
table_count_result = driver.ExecuteScript("{ return document.querySelectorAll('.performance').length }")
|
||||
table_count = CInt(table_count_result)
|
||||
|
||||
' find max race_num
|
||||
Dim max_race_num As Integer
|
||||
|
||||
script_content = "{" & _
|
||||
" let all_a = {};" & _
|
||||
" all_a = document.querySelectorAll('.top_races a');" & _
|
||||
" return all_a?.item(all_a?.length-2)?.href?.split('=')[3] || 0;" & _
|
||||
"}"
|
||||
|
||||
|
||||
max_race_num = CInt(driver.ExecuteScript(script_content))
|
||||
|
||||
Dim i, j, k, l As Integer
|
||||
|
||||
Dim current_row As Integer
|
||||
current_row = row_offset
|
||||
|
||||
|
||||
For l = 1 To max_race_num
|
||||
driver.Get "https://racing.hkjc.com/racing/information/Chinese/Racing/LocalResults.aspx?RaceDate=" & race_date & "&RaceNo=" & CStr(l)
|
||||
script_content = "{" & _
|
||||
"list_e = [];" & _
|
||||
"document" & _
|
||||
" .querySelector('.performance table')" & _
|
||||
" .querySelectorAll('tr')" & _
|
||||
" .forEach((e_tr, idx) => {" & _
|
||||
" if (idx > 0) {" & _
|
||||
" let temp = e_tr.querySelectorAll('td');" & _
|
||||
" let temp_l = [];" & _
|
||||
" temp.forEach(e => temp_l.push(e.textContent.trim()));" & _
|
||||
" list_e.push(" & _
|
||||
" [" & _
|
||||
" temp_l.join(',')," & _
|
||||
" temp[9].textContent.replace(/[\n| ]+/g, '_').slice(1,-1)," & _
|
||||
" ].join(',')" & _
|
||||
" );" & _
|
||||
" }" & _
|
||||
" });" & _
|
||||
"return list_e.join('|||')" & _
|
||||
"}"
|
||||
script_result = driver.ExecuteScript(script_content)
|
||||
hourse_table = Split(script_result, "|||")
|
||||
|
||||
Dim table_race_date, race_course, race_number, total_race_number, race_cource_desc As String
|
||||
table_race_date = driver.ExecuteScript("{ return document.querySelector('div.raceMeeting_select')?.querySelectorAll('p')[0]?.querySelectorAll('span')[0]?.textContent.split(/ +/g)[1] || '-'}")
|
||||
race_course = driver.ExecuteScript("{ return document.querySelector('div.raceMeeting_select')?.querySelectorAll('p')[0]?.querySelectorAll('span')[0]?.textContent.split(/ +/g)[3] || '-'}")
|
||||
race_number = driver.ExecuteScript("{ return document.querySelectorAll('div.race_tab td')[0]?.textContent?.split(/\s\(/g)[0] || '-'; }")
|
||||
total_race_number = driver.ExecuteScript("{ return document.querySelectorAll('div.race_tab td')[0]?.textContent?.split(/ /g)[3]?.replace(/[\(|\)]/g,'') || '-'; }")
|
||||
race_cource_desc = driver.ExecuteScript("{ return document.querySelector('div.race_tab')?.querySelectorAll('td')[11]?.textContent || '-'; } ")
|
||||
|
||||
|
||||
For i = LBound(hourse_table) To UBound(hourse_table)
|
||||
Dim temp As Variant
|
||||
temp = Split(hourse_table(i), ",")
|
||||
|
||||
startCell.Offset(current_row, 30).value = table_race_date
|
||||
startCell.Offset(current_row, 31).value = race_course
|
||||
startCell.Offset(current_row, 32).value = race_number
|
||||
startCell.Offset(current_row, 33).value = total_race_number
|
||||
startCell.Offset(current_row, 34).value = race_cource_desc
|
||||
|
||||
startCell.Offset(current_row, 37).value = temp(2)
|
||||
startCell.Offset(current_row, 38).value = temp(3)
|
||||
startCell.Offset(current_row, 39).value = temp(4)
|
||||
startCell.Offset(current_row, 40).value = "'" & temp(7)
|
||||
startCell.Offset(current_row, 41).value = temp(5)
|
||||
startCell.Offset(current_row, 42).value = temp(6)
|
||||
startCell.Offset(current_row, 35).value = temp(0)
|
||||
startCell.Offset(current_row, 36).value = temp(1)
|
||||
startCell.Offset(current_row, 49).value = "'" & temp(8)
|
||||
startCell.Offset(current_row, 50).value = temp(11)
|
||||
|
||||
Dim temp_l As Variant
|
||||
temp_l = Split(temp(12), "_")
|
||||
For k = 0 To 5
|
||||
If (k >= UBound(temp_l)) Then
|
||||
startCell.Offset(current_row, 43 + k).value = "-"
|
||||
Else
|
||||
startCell.Offset(current_row, 43 + k).value = temp_l(k)
|
||||
End If
|
||||
Next k
|
||||
|
||||
current_row = current_row + 1
|
||||
Next i
|
||||
|
||||
|
||||
Dim num_of_horse As Integer
|
||||
Dim race_row_end As Integer
|
||||
race_row_end = current_row - 1
|
||||
|
||||
num_of_horse = UBound(hourse_table)
|
||||
|
||||
not_used = DisplaySectionalTime_aspx.ScrapeDisplaySectionalTime(driver, race_date, CStr(l), race_row_end - num_of_horse, num_of_horse)
|
||||
|
||||
Next l
|
||||
|
||||
|
||||
GoTo Done
|
||||
|
||||
ErrorHandler:
|
||||
MsgBox "hello error2"
|
||||
MsgBox "Error: " & Err.Description
|
||||
|
||||
Done:
|
||||
TidySheet
|
||||
|
||||
driver.Quit
|
||||
|
||||
|
||||
End Sub
|
||||
|
||||
Function ResetCell()
|
||||
Worksheets("Sheet1").Range("AE3:BF300").ClearContents
|
||||
End Function
|
||||
|
||||
Function TidySheet()
|
||||
Worksheets("Sheet1").Range("OK1:OK200").ClearContents
|
||||
|
||||
'widen column width
|
||||
Worksheets("Sheet1").Range("AE3:BF300").Columns.AutoFit
|
||||
|
||||
' align text to center
|
||||
Worksheets("Sheet1").Range("AE3:BF300").HorizontalAlignment = xlCenter
|
||||
|
||||
End Function
|
||||
|
||||
|
||||
' write cell
|
||||
Sub writeCell(cell_addres As String, value As String)
|
||||
|
||||
End Sub
|
||||
|
||||
|
||||
Private Sub Take_ScreenShot_Desktop()
|
||||
Dim utils As New utils
|
||||
Dim driver As New ChromeDriver
|
||||
driver.Get "https://en.wikipedia.org/wiki/Main_Page"
|
||||
|
||||
Dim img As Object
|
||||
|
||||
'take a screenshot of the desktop
|
||||
Set img = utils.TakeScreenshot()
|
||||
|
||||
'save the image in the folder of the workbook
|
||||
img.SaveAs ThisWorkbook.Path & "\sc-desktop.png"
|
||||
|
||||
driver.Quit
|
||||
End Sub
|
||||
|
||||
|
||||
|
4
abc2022d/task1/ticket0002/LocalTrackwork_aspx.bas
Normal file
4
abc2022d/task1/ticket0002/LocalTrackwork_aspx.bas
Normal file
@@ -0,0 +1,4 @@
|
||||
Attribute VB_Name = "LocalTrackwork_aspx"
|
||||
|
||||
Option Explicit
|
||||
|
303
abc2022d/task1/ticket0002/Racecard_aspx.bas
Normal file
303
abc2022d/task1/ticket0002/Racecard_aspx.bas
Normal file
@@ -0,0 +1,303 @@
|
||||
Attribute VB_Name = "Racecard_aspx"
|
||||
|
||||
Option Explicit
|
||||
|
||||
Public Sub ScrapeRacecard()
|
||||
Common.ResetSheet
|
||||
|
||||
Dim COL_IDX_HORSE_NO As Integer
|
||||
Dim COL_IDX_LAST_6_RUNS As Integer
|
||||
Dim COL_IDX_COLOUR As Integer
|
||||
Dim COL_IDX_HORSE As Integer
|
||||
Dim COL_IDX_BRAND_NO As Integer
|
||||
Dim COL_IDX_WT As Integer
|
||||
Dim COL_IDX_JOCKEY As Integer
|
||||
Dim COL_IDX_OVER_WT As Integer
|
||||
Dim COL_IDX_DRAW As Integer
|
||||
Dim COL_IDX_TRAINER As Integer
|
||||
Dim COL_IDX_RTG As Integer
|
||||
Dim COL_IDX_RTG_PLUS_MINUS As Integer
|
||||
Dim COL_IDX_HORSE_WT_DECLARATION As Integer
|
||||
Dim COL_IDX_WT_PLUS_MINUS_VS_DECLARATION As Integer
|
||||
Dim COL_IDX_BEST_TIME As Integer
|
||||
Dim COL_IDX_AGE As Integer
|
||||
Dim COL_IDX_WFA As Integer
|
||||
Dim COL_IDX_SEX As Integer
|
||||
Dim COL_IDX_SEASON_STAKES As Integer
|
||||
Dim COL_IDX_PRIORITY As Integer
|
||||
Dim COL_IDX_DAYS_SINCE_LAST_RUN As Integer
|
||||
Dim COL_IDX_GEAR As Integer
|
||||
Dim COL_IDX_OWNER As Integer
|
||||
Dim COL_IDX_SIRE As Integer
|
||||
Dim COL_IDX_DAM As Integer
|
||||
Dim COL_IDX_IMPORT_CAT As Integer
|
||||
|
||||
Dim i, j, k, l, m As Integer
|
||||
Dim not_used As String
|
||||
|
||||
Dim CURRENT_DIR As String
|
||||
CURRENT_DIR = ThisWorkbook.Path
|
||||
|
||||
' Create a new instance of the WebDriver.
|
||||
Dim driver As New WebDriver
|
||||
|
||||
' Set the path to the WebDriver executable.
|
||||
driver.SetBinary CURRENT_DIR & "\Chromium\Application\chrome.exe"
|
||||
driver.AddArgument "--disable-blink-features=AutomationControlled --blink-settings=imagesEnabled=false"
|
||||
|
||||
' Start Chrome.
|
||||
driver.Start "chrome"
|
||||
|
||||
' not_used = Common.WriteCell(s"A3","helloworld")
|
||||
|
||||
Dim startCell As Range
|
||||
Set startCell = Worksheets("Sheet1").Range("A3")
|
||||
|
||||
Dim row_offset, row_offset_start As Integer
|
||||
row_offset = 0
|
||||
row_offset_start = 0
|
||||
|
||||
Dim driver1 As New WebDriver
|
||||
driver1.SetBinary CURRENT_DIR & "\Chromium\Application\chrome.exe"
|
||||
driver1.AddArgument "--disable-blink-features=AutomationControlled --blink-settings=imagesEnabled=false"
|
||||
driver1.Start "chrome"
|
||||
|
||||
driver.Get "https://racing.hkjc.com/racing/information/English/Racing/Racecard.aspx"
|
||||
Dim race_links_scraped, race_links As Variant
|
||||
race_links_scraped = driver.ExecuteScript( _
|
||||
"let links = [];" & _
|
||||
"document" & _
|
||||
" .querySelectorAll('.top_races')[0]" & _
|
||||
" .querySelectorAll('a')" & _
|
||||
" .forEach((e) => links.push(e.href));" & _
|
||||
"first_race_link = links[0].replace('RaceNo=2', 'RaceNo=1');" & _
|
||||
"links = [first_race_link, ...links];" & _
|
||||
"return links.join('||');" _
|
||||
)
|
||||
race_links = Split(race_links_scraped, "||")
|
||||
|
||||
|
||||
Dim first_race_link, last_race_link As String
|
||||
first_race_link = race_links(0)
|
||||
last_race_link = race_links(UBound(race_links))
|
||||
Dim s_date, s_loc, s_race_num As String
|
||||
Dim i_num As Integer
|
||||
|
||||
s_date = CStr(getDateFrRaceCardLink(first_race_link)(0))
|
||||
s_loc = CStr(getDateFrRaceCardLink(first_race_link)(1))
|
||||
s_race_num = CStr(getDateFrRaceCardLink(last_race_link)(2))
|
||||
i_num = CInt(s_race_num)
|
||||
|
||||
Dim race_link as Variant
|
||||
|
||||
' on error goto eh
|
||||
On Error GoTo ErrorHandler
|
||||
|
||||
|
||||
For Each race_link In race_links
|
||||
' For m = 1 To i_num 'i_num
|
||||
' Navigate to a website.
|
||||
' driver.Get "https://racing.hkjc.com/racing/information/Chinese/Racing/Racecard.aspx?RaceDate=" & s_date & "&Racecourse=" & s_loc & "&RaceNo=" & CStr(m)
|
||||
|
||||
Dim chinese_race_link as String
|
||||
chinese_race_link = replace(race_link, "English","Chinese")
|
||||
driver.Get chinese_race_link
|
||||
|
||||
driver.FindElementsByTag ("td")
|
||||
' document.querySelectorAll('#racecardlist tbody tr')[2].textContent
|
||||
|
||||
Dim race_summary_content, race_summary_result As String
|
||||
' document.querySelectorAll('.raceCard div')[6].textContent.split(',').map(l => l.replace(/\n/g,'').trim()).filter(l => l.trim() != '')
|
||||
race_summary_content = "{ return document.querySelectorAll('.raceCard div')[8]?.innerHTML.replace(/<br>/g,', ').split(', ').join('|||') }"
|
||||
race_summary_result = driver.ExecuteScript(race_summary_content)
|
||||
|
||||
Dim course_name As String
|
||||
Dim course_length As String
|
||||
Dim course_class As String
|
||||
Dim course_condition As String
|
||||
Dim mark_range As String
|
||||
|
||||
course_name = driver.ExecuteScript("{return document.querySelectorAll('.raceCard div')[8]?.innerHTML.split(/<br>/g)[2].split(', ').reverse().slice(2).join(' ')}")
|
||||
course_length = driver.ExecuteScript("{return document.querySelectorAll('.raceCard div')[8]?.innerHTML.split(/<br>/g)[2].split(', ').reverse()[1]}")
|
||||
course_class = driver.ExecuteScript("{return document.querySelectorAll('.raceCard div')[8]?.innerHTML.split(/<br>/g)[3].split(', ').reverse()[0] }")
|
||||
course_condition = driver.ExecuteScript("{return document.querySelectorAll('.raceCard div')[8]?.innerHTML.split(/<br>/g)[2].split(', ').reverse()[0] }")
|
||||
mark_range = driver.ExecuteScript("{return document.querySelectorAll('.raceCard div')[8]?.innerHTML.split(/<br>/g)[3].split(', ').reverse()[1].split(': ')[1] }")
|
||||
|
||||
row_offset_start = row_offset
|
||||
|
||||
Dim actual_horse_count As Integer
|
||||
actual_horse_count = 0
|
||||
|
||||
For j = 0 To 30
|
||||
|
||||
Dim s_test, s_test_result As String
|
||||
s_test = "{ return document.querySelectorAll('#racecardlist tbody tr td')[" & (27) + j * 27 + 1 & "]?.textContent.trim()||'not found' }"
|
||||
s_test_result = driver.ExecuteScript(s_test)
|
||||
|
||||
If (s_test_result = "not found") Then
|
||||
|
||||
Else
|
||||
actual_horse_count = actual_horse_count + 1
|
||||
|
||||
Dim horse_id As String
|
||||
|
||||
Dim s_content, s_result As String
|
||||
'1 ???? --> Horse No.
|
||||
s_content = "{ return document.querySelectorAll('#racecardlist tbody tr td')[" & (27) + j * 27 + 1 & "].textContent.trim() }"
|
||||
s_result = driver.ExecuteScript(s_content)
|
||||
startCell.Offset(row_offset, 1).value = s_result
|
||||
|
||||
'2 6??? --> Last 6 Runs
|
||||
'3 ?? --> Colour
|
||||
'4 ?? --> Horse
|
||||
s_content = "{ return document.querySelectorAll('#racecardlist tbody tr td')[" & (27) + j * 27 + 4 & "].textContent.trim() }"
|
||||
s_result = driver.ExecuteScript(s_content)
|
||||
startCell.Offset(row_offset, 2).value = s_result
|
||||
|
||||
horse_id = driver.ExecuteScript("{ return document.querySelectorAll('#racecardlist tbody tr td')[" & (27) + j * 27 + 4 & "].querySelector('a').href.split('=')[1] }")
|
||||
startCell.Offset(row_offset, 400).value = horse_id
|
||||
|
||||
'5 ?? --> Brand No.
|
||||
s_content = "{ return document.querySelectorAll('#racecardlist tbody tr td')[" & (27) + j * 27 + 5 & "].textContent.trim() }"
|
||||
s_result = driver.ExecuteScript(s_content)
|
||||
startCell.Offset(row_offset, 0).value = s_result
|
||||
|
||||
'6 ?? --> Wt.
|
||||
s_content = "{ return document.querySelectorAll('#racecardlist tbody tr td')[" & (27) + j * 27 + 6 & "].textContent.trim() }"
|
||||
s_result = driver.ExecuteScript(s_content)
|
||||
startCell.Offset(row_offset, 7).value = s_result
|
||||
|
||||
'7 ?? --> Jockey
|
||||
s_content = "{ return document.querySelectorAll('#racecardlist tbody tr td')[" & (27) + j * 27 + 7 & "].textContent.trim() }"
|
||||
s_result = driver.ExecuteScript(s_content)
|
||||
startCell.Offset(row_offset, 3).value = s_result
|
||||
|
||||
'8 ???? --> Over Wt.
|
||||
'9 ?? --> Draw
|
||||
s_content = "{ return document.querySelectorAll('#racecardlist tbody tr td')[" & (27) + j * 27 + 9 & "].textContent.trim() }"
|
||||
s_result = driver.ExecuteScript(s_content)
|
||||
startCell.Offset(row_offset, 5).value = s_result
|
||||
|
||||
'10 ??? --> Trainer
|
||||
s_content = "{ return document.querySelectorAll('#racecardlist tbody tr td')[" & (27) + j * 27 + 10 & "].textContent.trim() }"
|
||||
s_result = driver.ExecuteScript(s_content)
|
||||
startCell.Offset(row_offset, 4).value = s_result
|
||||
|
||||
'11 ?? --> Rtg.
|
||||
s_content = "{ return document.querySelectorAll('#racecardlist tbody tr td')[" & (27) + j * 27 + 12 & "].textContent.trim() }"
|
||||
s_result = driver.ExecuteScript(s_content)
|
||||
startCell.Offset(row_offset, 8).value = s_result
|
||||
|
||||
'12 ??+/- --> Rtg.+/-
|
||||
'13 ???? --> Horse Wt. (Declaration)
|
||||
s_content = "{ return document.querySelectorAll('#racecardlist tbody tr td')[" & (27) + j * 27 + 13 & "].textContent.trim() }"
|
||||
s_result = driver.ExecuteScript(s_content)
|
||||
startCell.Offset(row_offset, 9).value = s_result
|
||||
|
||||
'14 ????+/- --> Wt.+/- (vs Declaration)
|
||||
'15 ???? --> Best Time
|
||||
'16 ?? --> Age
|
||||
s_content = "{ return document.querySelectorAll('#racecardlist tbody tr td')[" & (27) + j * 27 + 17 & "].textContent.trim() }"
|
||||
s_result = driver.ExecuteScript(s_content)
|
||||
startCell.Offset(row_offset, 6).value = s_result
|
||||
|
||||
'17 ???? --> WFA
|
||||
'18 ?? --> Sex
|
||||
s_content = "{ return document.querySelectorAll('#racecardlist tbody tr td')[" & (27) + j * 27 + 19 & "].textContent.trim() }"
|
||||
s_result = driver.ExecuteScript(s_content)
|
||||
startCell.Offset(row_offset, 10).value = s_result
|
||||
|
||||
'19 ???? --> Season Stakes
|
||||
'20 ?????? --> Priority
|
||||
'21 ?????? --> Days since Last Run
|
||||
s_content = "{ return document.querySelectorAll('#racecardlist tbody tr td')[" & (27) + j * 27 + 22 & "].textContent.trim() }"
|
||||
s_result = driver.ExecuteScript(s_content)
|
||||
startCell.Offset(row_offset, 12).value = s_result
|
||||
|
||||
'22 ?? --> Gear
|
||||
s_content = "{ return document.querySelectorAll('#racecardlist tbody tr td')[" & (27) + j * 27 + 23 & "].textContent.trim() }"
|
||||
s_result = driver.ExecuteScript(s_content)
|
||||
startCell.Offset(row_offset, 11).value = s_result
|
||||
|
||||
'23 ?? --> Owner
|
||||
'24 ?? --> Sire
|
||||
s_content = "{ return document.querySelectorAll('#racecardlist tbody tr td')[" & (27) + j * 27 + 25 & "].textContent.trim() }"
|
||||
s_result = driver.ExecuteScript(s_content)
|
||||
startCell.Offset(row_offset, 13).value = s_result
|
||||
|
||||
'25 ?? --> Dam
|
||||
s_content = "{ return document.querySelectorAll('#racecardlist tbody tr td')[" & (27) + j * 27 + 26 & "].textContent.trim() }"
|
||||
s_result = driver.ExecuteScript(s_content)
|
||||
startCell.Offset(row_offset, 14).value = s_result
|
||||
|
||||
'26 ???? --> Import Cat.
|
||||
|
||||
|
||||
startCell.Offset(row_offset, 15).value = Split(race_summary_result, "|||")(1)
|
||||
startCell.Offset(row_offset, 16).value = Split(race_summary_result, "|||")(3)
|
||||
startCell.Offset(row_offset, 17).value = course_length
|
||||
startCell.Offset(row_offset, 18).value = course_name
|
||||
startCell.Offset(row_offset, 19).value = course_class
|
||||
startCell.Offset(row_offset, 20).value = course_condition
|
||||
startCell.Offset(row_offset, 21).value = mark_range
|
||||
startCell.Offset(row_offset, 22).value = Split(Split(Split(race_summary_result, "|||")(0), " - ")(0), " ")(2)
|
||||
|
||||
|
||||
not_used = Horse_aspx.ScrapeHorse(driver1, startCell.Offset(row_offset, 400).value, CStr(row_offset))
|
||||
|
||||
not_used = TrackworkResult_aspx.Scrape(driver1, startCell.Offset(row_offset, 400).value, row_offset, s_date)
|
||||
|
||||
row_offset = row_offset + 1
|
||||
End If
|
||||
|
||||
Next j
|
||||
|
||||
'not_used = LocalResults_aspx.ScrapeLocalResults(driver1, s_date, CStr(m), row_offset_start, actual_horse_count)
|
||||
'not_used = DisplaySectionalTime_aspx.ScrapeDisplaySectionalTime(driver1, s_date, CStr(m), row_offset_start, actual_horse_count)
|
||||
|
||||
' Next m
|
||||
Next race_link
|
||||
|
||||
GoTo Done
|
||||
|
||||
ErrorHandler:
|
||||
MsgBox "Error: " & Err.Description
|
||||
|
||||
Done:
|
||||
driver.Quit
|
||||
driver1.Quit
|
||||
|
||||
Common.ResumeScreenUpdate
|
||||
|
||||
Common.TidySheet
|
||||
|
||||
End Sub
|
||||
|
||||
|
||||
|
||||
' write cell
|
||||
Sub writeCell(cell_addres As String, value As String)
|
||||
|
||||
End Sub
|
||||
|
||||
|
||||
Private Sub Take_ScreenShot_Desktop()
|
||||
Dim utils As New utils
|
||||
Dim driver As New ChromeDriver
|
||||
driver.Get "https://en.wikipedia.org/wiki/Main_Page"
|
||||
|
||||
Dim img As Object
|
||||
|
||||
'take a screenshot of the desktop
|
||||
Set img = utils.TakeScreenshot()
|
||||
|
||||
'save the image in the folder of the workbook
|
||||
img.SaveAs ThisWorkbook.Path & "\sc-desktop.png"
|
||||
|
||||
driver.Quit
|
||||
End Sub
|
||||
|
||||
|
||||
|
||||
|
||||
|
122
abc2022d/task1/ticket0002/TrackworkResult_aspx.bas
Normal file
122
abc2022d/task1/ticket0002/TrackworkResult_aspx.bas
Normal file
@@ -0,0 +1,122 @@
|
||||
Attribute VB_Name = "TrackworkResult_aspx"
|
||||
|
||||
Option Explicit
|
||||
|
||||
|
||||
Public Sub test()
|
||||
'horse_id = "HK_2022_H195"
|
||||
'row_offset = 0
|
||||
Dim horse_id As String
|
||||
Dim row_offset As String
|
||||
|
||||
|
||||
' Create a new instance of the WebDriver.
|
||||
Dim driver As New WebDriver
|
||||
|
||||
' Set the path to the WebDriver executable.
|
||||
driver.SetBinary "C:\Users\logic\AppData\Local\Chromium\Application\chrome.exe"
|
||||
|
||||
' Start Chrome.
|
||||
driver.Start "chrome"
|
||||
|
||||
|
||||
Dim not_use As String
|
||||
not_use = TrackworkResult_aspx.Scrape(driver, "HK_2022_H195", 0, "2024/04/20")
|
||||
|
||||
|
||||
driver.Quit
|
||||
|
||||
End Sub
|
||||
|
||||
Public Function Scrape(driver As WebDriver, horse_id As String, ByVal row_offset As Integer, ByVal s_date As String)
|
||||
|
||||
Dim script_content As String
|
||||
|
||||
' Create a new instance of the WebDriver.
|
||||
'Dim driver As New WebDriver
|
||||
|
||||
' Set the path to the WebDriver executable.
|
||||
'driver.SetBinary "C:\Users\logic\AppData\Local\Chromium\Application\chrome.exe"
|
||||
|
||||
' Start Chrome.
|
||||
'driver.Start "chrome"
|
||||
|
||||
' Navigate to a website.
|
||||
driver.Get "https://racing.hkjc.com/racing/information/English/Trackwork/TrackworkResult.aspx?HorseId=" & horse_id
|
||||
|
||||
' document.querySelectorAll('#racecardlist tbody tr')[2].textContent
|
||||
Dim i, j As Integer
|
||||
|
||||
|
||||
Dim startCell As Range
|
||||
Set startCell = Worksheets("Sheet1").Range("A3")
|
||||
|
||||
Dim all_row As String
|
||||
|
||||
script_content = "{" & _
|
||||
"list_e = [];" & _
|
||||
"document.querySelector('div.performance table').querySelectorAll('tr').forEach((r,i) => {" & _
|
||||
" if (i > 0) list_e.push(r.textContent.replace(/\n +/g,'___').slice(3,-3));" & _
|
||||
"});" & _
|
||||
"return list_e.join('|||');" & _
|
||||
"}"
|
||||
|
||||
all_row = driver.ExecuteScript(script_content)
|
||||
|
||||
Dim table_rows As Variant
|
||||
table_rows = Split(all_row, "|||")
|
||||
|
||||
For i = 0 To UBound(table_rows) - 1
|
||||
|
||||
Dim td_s As Variant
|
||||
|
||||
Dim event_date As String
|
||||
td_s = Split(table_rows(i), "___")
|
||||
event_date = td_s(0)
|
||||
|
||||
Dim event_person as String
|
||||
td_s = Split(table_rows(i), "___")
|
||||
event_person = td_s(3)
|
||||
|
||||
|
||||
Dim date_diff As Integer
|
||||
date_diff = DateDiff("d", Common.ParseDDMMYYYY(event_date), s_date)
|
||||
|
||||
If (date_diff <= 20) Then
|
||||
If (InStr(td_s(1), "Barrier Trial") > 0) Then
|
||||
startCell.Offset(row_offset, 24).value = "Y"
|
||||
If (startCell.Offset(row_offset, 25).value = "") Then
|
||||
startCell.Offset(row_offset, 25).value = event_date
|
||||
Else
|
||||
startCell.Offset(row_offset, 25).value = startCell.Offset(row_offset, 25).value & "," & event_date
|
||||
End If
|
||||
End If
|
||||
|
||||
|
||||
If (InStr(td_s(1), "Gallop") > 0) Then
|
||||
' Gallop by R.B. ?
|
||||
if (InStr(event_person, "R.B.") > 0) Then
|
||||
startCell.Offset(row_offset, 26).value = "Y"
|
||||
end if
|
||||
|
||||
If (startCell.Offset(row_offset, 27).value = "") Then
|
||||
startCell.Offset(row_offset, 27).value = event_date
|
||||
Else
|
||||
startCell.Offset(row_offset, 27).value = startCell.Offset(row_offset, 27).value & "," & event_date
|
||||
' Dim current_cell As Variant
|
||||
' Set current_cell = startCell.Offset(0, 27)
|
||||
' current_cell.Hyperlinks.Add Anchor:=current_cell, Address:="https://racing.hkjc.com/racing/information/Chinese/Horse/Horse.aspx?HorseId=" & horse_id
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
|
||||
Next
|
||||
|
||||
'driver.Quit
|
||||
|
||||
End Function
|
||||
|
||||
|
||||
|
||||
|
||||
|
5
abc2022d/task1/ticket0002/dev.bat
Normal file
5
abc2022d/task1/ticket0002/dev.bat
Normal file
@@ -0,0 +1,5 @@
|
||||
@REM start excel by yourself
|
||||
|
||||
@REM ./test.xlsm
|
||||
|
||||
xlwings vba edit --file ./main.xlsm
|
3
abc2022d/task1/ticket0002/gitUpdate.bat
Normal file
3
abc2022d/task1/ticket0002/gitUpdate.bat
Normal file
@@ -0,0 +1,3 @@
|
||||
git add .
|
||||
git commit -m"update ticket0002,"
|
||||
start git push
|
17
abc2022d/task1/ticket0002/history.md
Normal file
17
abc2022d/task1/ticket0002/history.md
Normal file
@@ -0,0 +1,17 @@
|
||||
# history
|
||||
|
||||
## ticket0001
|
||||
|
||||
### Q
|
||||
|
||||
Hello 你好, 關於之前揾你幫手寫個 VBA , 發現了有 error 想揾你 fix
|
||||
|
||||
以下圖第 6 場 4 號勤德威力為例,
|
||||
我剛 gen 左個 excel ,
|
||||
發現佢無試閘但 vba show 左佢有試閘同試閘日期,
|
||||
同埋佢快操日期亦錯,
|
||||
以及佢之前 ge 快操並沒有由副練去做,
|
||||
煩請更正,
|
||||
謝謝
|
||||
|
||||
### Drill
|
BIN
abc2022d/task1/ticket0002/main.xlsm
Normal file
BIN
abc2022d/task1/ticket0002/main.xlsm
Normal file
Binary file not shown.
Reference in New Issue
Block a user