update,
This commit is contained in:
87
abc2022d/task1/ticket0001/Horse_aspx.bas
Normal file
87
abc2022d/task1/ticket0001/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
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user