naru Posted March 17, 2019 Posted March 17, 2019 Hello, I want to read the date (Not time) from webpage. its possible to read it ? Inspect Element :
alienclone Posted March 17, 2019 Posted March 17, 2019 it is possible. for Internet Explorer check out the IE.udf for chrome or ff check out IUIAutomation If @error Then MsgBox(262192, "", @ComputerName & " slaps " & @UserName & " around a bit with a large trout!") EndIf "Yeah yeah yeah patience, how long will that take?" -Ed Gruberman REAL search results | SciTE4AutoIt3 Editor Full Version
naru Posted March 17, 2019 Author Posted March 17, 2019 (edited) Just now, alienclone said: it is possible. for Internet Explorer check out the IE.udf for chrome or ff check out IUIAutomation i am trying with this code : #include <IE.au3> $oIE = _IEAttach ("Home") Local $date = "Be", $idate = "0" Local $oTds = _IETagNameGetCollection($oIE, "li") For $oTd In $oTds If $oTd.InnerText = $date Then $idate = $oTd.NextElementSibling.InnerText EndIf Next MsgBox(0, "date is", $idate) But, 1) It was showing date with time, i want to read only date. 2) Sometime the server changed then the previous li tag is : Be/Ga/De Edited March 17, 2019 by naru added code
Exit Posted March 17, 2019 Posted March 17, 2019 Can you give us the URL of the webpage? App: Au3toCmd UDF: _SingleScript()
naru Posted March 17, 2019 Author Posted March 17, 2019 Just now, Exit said: Can you give us the URL of the webpage? no, Sorry
rm4453 Posted March 17, 2019 Posted March 17, 2019 (edited) If you are getting the correct string, just string split it after you get it with: #include <IE.au3> $oIE = _IEAttach ("Home") Local $idate = "0" Local $date[3] = ["Be", "Ga", "De"] ; Creating array with these options to compare against: Be/Ga/De Local $oTds = _IETagNameGetCollection($oIE, "li") For $y in $date ; Using an extra loop to loop through the array options to verify against all 3 possibilities For $oTd In $oTds If $oTd.InnerText = $y Then $idate = $oTd.NextElementSibling.InnerText $idate = StringSplit($idate, " ") EndIf Next Next MsgBox(0, "date is", $idate[1]) Edited March 17, 2019 by rm4453 Added For Loop to verify li vs all array options: Be/Ga/De
naru Posted March 17, 2019 Author Posted March 17, 2019 28 minutes ago, rm4453 said: If you are getting the correct string, just string split it after you get it with: #include <IE.au3> $oIE = _IEAttach ("Home") Local $idate = "0" Local $date[3] = ["Be", "Ga", "De"] ; Creating array with these options to compare against: Be/Ga/De Local $oTds = _IETagNameGetCollection($oIE, "li") For $y in $date ; Using an extra loop to loop through the array options to verify against all 3 possibilities For $oTd In $oTds If $oTd.InnerText = $y Then $idate = $oTd.NextElementSibling.InnerText $idate = StringSplit($idate, " ") EndIf Next Next MsgBox(0, "date is", $idate[1]) error in last line
rm4453 Posted March 17, 2019 Posted March 17, 2019 2 minutes ago, naru said: error in last line #include <IE.au3> $oIE = _IEAttach ("Home") Local $idate = "0" Local $date[3] = ["Be", "Ga", "De"] ; Creating array with these options to compare against: Be/Ga/De Local $oTds = _IETagNameGetCollection($oIE, "li") For $y in $date ; Using an extra loop to loop through the array options to verify against all 3 possibilities $z = false For $oTd In $oTds If $oTd.InnerText = $y Then $idate = $oTd.NextElementSibling.InnerText $idate = StringSplit($idate, " ") $z = true EndIf If $z = true Then ExitLoop Next If $z = true Then ExitLoop Next If $z = true Then MsgBox(0, "date is ", $idate[1]) Else MsgBox(0, "DATE NOT FOUND: ", $idate) EndIf
naru Posted March 17, 2019 Author Posted March 17, 2019 2 minutes ago, rm4453 said: #include <IE.au3> $oIE = _IEAttach ("Home") Local $idate = "0" Local $date[3] = ["Be", "Ga", "De"] ; Creating array with these options to compare against: Be/Ga/De Local $oTds = _IETagNameGetCollection($oIE, "li") For $y in $date ; Using an extra loop to loop through the array options to verify against all 3 possibilities $z = false For $oTd In $oTds If $oTd.InnerText = $y Then $idate = $oTd.NextElementSibling.InnerText $idate = StringSplit($idate, " ") $z = true EndIf If $z = true Then ExitLoop Next If $z = true Then ExitLoop Next If $z = true Then MsgBox(0, "date is ", $idate[1]) Else MsgBox(0, "DATE NOT FOUND: ", $idate) EndIf Getting empty Box : Some time the server is different than Be/Ga/De
rm4453 Posted March 17, 2019 Posted March 17, 2019 Just now, naru said: Getting empty Box : Some time the server is different than Be/Ga/De what are the server options? you need a full list to compare against... also try changing the array output to 2 instead
Nine Posted March 17, 2019 Posted March 17, 2019 go with .className = "nav navbar-btn" instead “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
rm4453 Posted March 17, 2019 Posted March 17, 2019 (edited) Actually try this: #include <IE.au3> $oIE = _IEAttach ("Home") Local $idate = "0" Local $date[3] = ["Be", "Ga", "De"] ; Creating array with these options to compare against: Be/Ga/De Local $oTds = _IETagNameGetCollection($oIE, "nav navbar-btn") ; Added Nine's Suggestion For $y in $date ; Using an extra loop to loop through the array options to verify against all 3 possibilities $z = false For $oTd In $oTds If $oTd.InnerText = $y Then $idate = $oTd.NextElementSibling.InnerText $idate = StringSplit($idate, " ") $z = true EndIf If $z = true Then ExitLoop Next If $z = true Then ExitLoop Next If $z = true Then For $i = 1 To $idate MsgBox(0, "date is ", $idate[$i]) Next Else MsgBox(0, "DATE NOT FOUND: ", $idate) EndIf Edited March 17, 2019 by rm4453
naru Posted March 17, 2019 Author Posted March 17, 2019 (edited) 35 minutes ago, rm4453 said: what are the server options? you need a full list to compare against... also try changing the array output to 2 instead @rm4453, @Exit Please Check out the webpage : (for security reason i will delete it) Edited March 17, 2019 by naru remove webpage
naru Posted March 17, 2019 Author Posted March 17, 2019 3 minutes ago, rm4453 said: Actually try this: #include <IE.au3> $oIE = _IEAttach ("Home") Local $idate = "0" Local $date[3] = ["Be", "Ga", "De"] ; Creating array with these options to compare against: Be/Ga/De Local $oTds = _IETagNameGetCollection($oIE, "nav navbar-btn") ; Added Nine's Suggestion For $y in $date ; Using an extra loop to loop through the array options to verify against all 3 possibilities $z = false For $oTd In $oTds If $oTd.InnerText = $y Then $idate = $oTd.NextElementSibling.InnerText $idate = StringSplit($idate, " ") $z = true EndIf If $z = true Then ExitLoop Next If $z = true Then ExitLoop Next If $z = true Then For $i = 1 To $idate MsgBox(0, "date is ", $idate[$i]) Next Else MsgBox(0, "DATE NOT FOUND: ", $idate) EndIf Not getting anything.
Nine Posted March 17, 2019 Posted March 17, 2019 no you still to get the same collection, but you need to compare with classname instead of innertext “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
rm4453 Posted March 17, 2019 Posted March 17, 2019 (edited) 1 minute ago, naru said: Not getting anything. Oops one moment didn't write loop correctly: #include <IE.au3> $oIE = _IEAttach ("Home") Local $idate = "0" Local $date[3] = ["Be", "Ga", "De"] ; Creating array with these options to compare against: Be/Ga/De Local $oTds = _IETagNameGetCollection($oIE, "nav navbar-btn") ; Added Nine's Suggestion For $y in $date ; Using an extra loop to loop through the array options to verify against all 3 possibilities $z = false For $oTd In $oTds If $oTd.InnerText = $y Then $idate = $oTd.NextElementSibling.ClassName $idate = StringSplit($idate, " ") $z = true EndIf If $z = true Then ExitLoop Next If $z = true Then ExitLoop Next If $z = true Then For $i = 1 To $idate[0] MsgBox(0, "date is ", $idate[$i]) Next Else MsgBox(0, "DATE NOT FOUND: ", $idate) EndIf Edited March 17, 2019 by rm4453
naru Posted March 17, 2019 Author Posted March 17, 2019 3 minutes ago, rm4453 said: Oops one moment didn't write loop correctly: #include <IE.au3> $oIE = _IEAttach ("Home") Local $idate = "0" Local $date[3] = ["Be", "Ga", "De"] ; Creating array with these options to compare against: Be/Ga/De Local $oTds = _IETagNameGetCollection($oIE, "nav navbar-btn") ; Added Nine's Suggestion For $y in $date ; Using an extra loop to loop through the array options to verify against all 3 possibilities $z = false For $oTd In $oTds If $oTd.InnerText = $y Then $idate = $oTd.NextElementSibling.ClassName $idate = StringSplit($idate, " ") $z = true EndIf If $z = true Then ExitLoop Next If $z = true Then ExitLoop Next If $z = true Then For $i = 1 To $idate[0] MsgBox(0, "date is ", $idate[$i]) Next Else MsgBox(0, "DATE NOT FOUND: ", $idate) EndIf Showing DATE NOT FOUND msgbox
Nine Posted March 17, 2019 Posted March 17, 2019 #include <IE.au3> $oIE = _IEAttach ("Home") Local $date Local $oTds = _IETagNameGetCollection($oIE, "li") For $oTd In $oTds If $oTd.className = "nav navbar-btn" Then $idate = StringSplit($oTd.NextElementSibling.InnerText, " ")[1] ExitLoop EndIf Next MsgBox(0, "date is", $idate) Try this “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
naru Posted March 17, 2019 Author Posted March 17, 2019 2 minutes ago, Nine said: #include <IE.au3> $oIE = _IEAttach ("Home") Local $date Local $oTds = _IETagNameGetCollection($oIE, "li") For $oTd In $oTds If $oTd.className = "nav navbar-btn" Then $idate = StringSplit($oTd.NextElementSibling.InnerText, " ")[1] ExitLoop EndIf Next MsgBox(0, "date is", $idate) Try this Got empty msg box, Please check webpage
rm4453 Posted March 17, 2019 Posted March 17, 2019 Just now, naru said: Got empty msg box, Please check webpage Here: #include <IE.au3> $oIE = _IEAttach ("Home") Local $date Local $oTds = _IETagNameGetCollection($oIE, "li") For $oTd In $oTds If $oTd.className = "nav navbar-btn" Then $idate = StringSplit($oTd.NextElementSibling.InnerText, " ")[2] ; Because there is a space at beginning it parses that in first spot so we show 2nd ExitLoop EndIf Next MsgBox(0, "date is", $idate)
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now