You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
2.0 KiB
Plaintext

; Iterate over Locals posts on the home page until found post with title
; ------------------------------------------------
GrabLocalsPostURLUsingTitle(PostTitle){
Loop, 10 {
Message = Checking Post %A_index% on page for Post Titled`n%PostTitle%
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
ToolTip, %A_Index%
; first two items can be skipped.
; new Post box and Create other forms of posts box
if(A_index < 3)
Continue
; Xpath for each post box on the main page
Xpath = //body/div/div/div/div/div/div[1]/div[%A_Index%]
try ElementInnerText := driver.findelementbyxpath(Xpath).Attribute("innerText") ;XPATH Inner Text
Try ElementOuterHTML := driver.findelementbyxpath(Xpath).Attribute("outerHTML") ;XPATH-ID & Tag
if(Devmode){
Msgbox % "ElementInnerText: " ElementInnerText "`n" "ElementOuterHTML: " ElementOuterHTML
}
if(InStr(ElementInnerText, PostTitle)){
Message = Found Post Title in Element Number: %A_index%
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
; Pull Out the Post URL from the OuterHTML using RegEx
regexMatch := RegExMatch(ElementOuterHTML, "data-post-url=""([^""]+)""", match)
if (regexMatch)
{
PostURL := match1
Message = URL Pulled out from OuterHTML: %PostURL%
Return PostURL
}
else {
Message = Failed to Pull out URL from OuterHTML
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
Return "Failed"
}
}
}
Message = Failed to find New Post in the first 10 posts
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
Return "Failed"
}