Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #NoEnv
- SetBatchLines, -1
- #SingleInstance force
- StringCaseSense, Locale
- #IfWinActive, (*_*)
- Array_id := {"career-splits" :"career-splits-chall", "last52-splits":"last52-splits-chall"}
- split_x := "4"
- split_y := "3"
- ToolTip, Поиск последнего ранга!!
- html := WebRequest("https://tennisabstract.com/reports/wtaRankings.html",,,, error)
- if error
- throw error
- document := DocumentFromHtml(html)
- links := document.getElementsByTagName("tbody")[3].getElementsByTagName("tr")
- loop, % links.length
- {
- if (A_index = links.length -1)
- global end_pos := links[A_Index].getElementsByTagName("td")[0].innerText
- }
- ToolTip
- Gui, +ToolWindow +AlwaysOnTop
- Gui,Font, s15 normal
- Gui, Add, Edit, r1 x20 w150 vSearch gValidCheck Number, % "Rank_1-" end_pos
- Gui, Add, Button, x20 y+10 w150 h20 Disabled vnext gOK, % Chr(0x2192)
- Gui,Font, s12 normal
- Gui, Add, Text, x20 y+10 w200 vName gname,
- Gui, Font, s10 normal
- Gui, Add, ListView, x10 y+15 r9 w304 NoSort vLV +ReadOnly , Split|M|W|L|Win
- loop % LV_GetCount("col")
- {
- if(A_index = "1")
- LV_ModifyCol(A_index,"115 Center")
- else if(A_index = LV_GetCount("col"))
- LV_ModifyCol(A_index,"65 Center")
- else
- LV_ModifyCol(A_index,"40 Center")
- }
- Gui, Add, Picture, x180 y5 w130 h100 vImages +0x1000,
- Gui, Show, w320, (*_*)
- hCurs:=DllCall("LoadCursor","UInt",NULL,"Int",32649,"UInt") ;IDC_HAND
- OnMessage(0x200,"WM_MOUSEMOVE")
- GuiControl, Focus, Search
- return
- GuiClose:
- ExitApp
- ValidCheck:
- GuiControlGet, Search
- If (isNumberInRange(Search,0) )
- GuiControl, Enable, next
- else
- GuiControl, Disable, next
- return
- name:
- run, % link_gui
- return
- $Enter::
- $NumpadEnter::
- Ok:
- Gui, Submit, NoHide
- gosub label_none
- ToolTip, Loading!!
- url := "https://tennisabstract.com/reports/wtaRankings.html"
- loop 3
- {
- html := WebRequest(url,,,, error)
- if error
- throw error
- document := DocumentFromHtml(html)
- if(A_index = 1)
- {
- links := document.getElementsByTagName("tbody")[3].getElementsByTagName("tr")
- loop, % links.length
- {
- if(search = links[A_index - 1].getElementsByTagName("td")[0].innerText)
- {
- url := link_gui:= links[A_index - 1].getElementsByTagName("td")[1].getElementsByTagName("a")[0].getAttribute("href")
- fullname := links[A_index - 1].getElementsByTagName("td")[1].getElementsByTagName("a")[0].innerText
- break
- }
- }
- }
- if(A_index = 2)
- {
- links := document.getElementsByTagName("head")[0].getElementsByTagName("script")
- loop, % links.length
- {
- if Instr(links[A_index - 1].getAttribute("src"), RegExReplace(fullname, "\s"))
- url:= links[A_index - 1].getAttribute("src")
- }
- }
- if(A_index = 3)
- {
- for key, var in Array_id
- {
- chek_tag := Instr(html, var) ? var : key
- list_tag.Push(chek_tag)
- a := 0
- loop, % split_y
- {
- b := 1
- Array_career.Push(document.getElementById(chek_tag).getElementsByTagName("tbody")[0].getElementsByTagName("tr")[a].getElementsByTagName("td")[0].innerText)
- loop, % split_x
- {
- Array_last52.Push(document.getElementById(chek_tag).getElementsByTagName("tbody")[0].getElementsByTagName("tr")[a].getElementsByTagName("td")[b].innerText)
- b++
- }
- a++
- }
- }
- }
- }
- GuiControl, Text, Name, % fullname
- for key, var_car in Array_career
- {
- if (key = 1)
- LV_Add(, "")
- if (key = split_y+1)
- {
- LV_Add(, "")
- LV_Add(, "")
- }
- LV_Add(, var_car)
- }
- i := 1
- col := 2
- for key, var_last in Array_last52
- {
- if(key = "5" || key = "9" || key = "13" || key = "17" || key = "21") ;(key = 4 * i + 1)
- {
- i++
- col := 2
- }
- if(key = "13")
- i := i+2
- LV_Modify(i+1, "Col" . col, var_last)
- col++
- }
- UrlDownloadToFile, % Format("{:L}", "https://www.tennisabstract.com/photos/" RegExReplace(fullname, " ", "_") "-sirobi.jpg"), % capture := A_Temp "\capture_tennis.jpg"
- FileGetSize, OutputVar_size, % capture , K
- if (OutputVar_size < 3)
- {
- if !FileExist(A_Temp "\capture_tennis_none.jpg")
- UrlDownloadToFile, https://t3.ftcdn.net/jpg/02/15/15/46/240_F_215154625_hJg9QkfWH9Cu6LCTUc8TiuV6jQSI0C5X.jpg, % capture := A_Temp "\capture_tennis_none.jpg"
- else
- capture := A_Temp "\capture_tennis_none.jpg"
- }
- GuiControl,, Images, *w130 *h100 %capture%
- GuiControl, Text, Search,
- for key, var in list_tag
- {
- if(key = 1)
- LV_Modify(1, "", var)
- else
- LV_Modify(6, "", var)
- }
- ToolTip
- return
- WebRequest(url, method := "GET", HeadersArray := "", body := "", ByRef error := "") {
- Whr := ComObjCreate("WinHttp.WinHttpRequest.5.1")
- try
- Whr.Open(method, url, true)
- catch
- {
- ToolTip
- MsgBox, 4112, , Error!!
- ExitApp
- }
- for name, value in HeadersArray
- Whr.SetRequestHeader(name, value)
- Whr.Send(body)
- Whr.WaitForResponse()
- status := Whr.status
- if (status != 200)
- error := "HttpRequest error, status: " . status
- Arr := Whr.responseBody
- pData := NumGet(ComObjValue(Arr) + 8 + A_PtrSize)
- length := Arr.MaxIndex() + 1
- Return StrGet(pData, length, "UTF-8")
- }
- DocumentFromHtml(html, mode := 9) {
- document := ComObjCreate("HTMLFILE")
- document.write("<meta http-equiv=""X-UA-Compatible"" content=""IE=" . mode . """>")
- document.write(html)
- Return document
- }
- WM_MOUSEMOVE(wParam,lParam)
- {
- If (A_GuiControl = "Search")
- {
- GuiControlGet, OutputVar,, Search
- if Instr(OutputVar, "Rank")
- GuiControl, Text, Search,
- }
- Global hCurs
- MouseGetPos,,,,ctrl
- IfInString ctrl, Static1
- DllCall("SetCursor","UInt",hCurs)
- Return
- }
- IsNumberInRange(var,low)
- {
- If (StrLen(var) > low && var != low && var < end_pos+1)
- Return 1
- }
- label_none:
- list_tag := {}
- Array_career := {}
- Array_last52 := {}
- chek_tag :=
- LV_Delete()
- GuiControl, Text, Name,
- GuiControl,, Images,
- fullname := ""
- return
- ^esc::ExitApp
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement