UNO Posted March 9, 2007 Share Posted March 9, 2007 Hi All,I have started using AutoIT and trying to create some POC to demonstrate to my co-workers.However I am stuck at the following level.Assuming that I have sent some data and clicked "submit" button in a webpage I get some status number/error .When i go to view-->source I see that I it is wrapped around the following line in a very big source file with lot of javascript<span class="status"> I4A50179 : Details are added successfully</span>I cant let my script to go to view->source coz i dont want the user to see this things happening.Also I can't search for span coz it gives a lot of instances of finding the source like finding <td colspan="2">Sometimes the error is displayed with multiple lines of span class code.Then i need them allIs there any function that can copy text between two words in the down order in a webpage.for eg between text "Loged in as" and "Announcement details"For example in the same webpage can I copy text between two words.that if possible would include all the status details after the action are performedOr after view->source how can I make the text file hidden copy the text between "<span class" and "</span>".Please note that sometimes it span multiple lines. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 9, 2007 Moderators Share Posted March 9, 2007 If you are using 3.2.2.0 Store the source in a variable with _InetGetSource(), and then look at _StringBetween(). Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
UNO Posted March 9, 2007 Author Share Posted March 9, 2007 If you are using 3.2.2.0Store the source in a variable with _InetGetSource(), and then look at _StringBetween().Thanks Smoke .I looked at the help file but i have some queries._InetGetSource() Gets the source from an URL without writing a temp file.#include <INet.au3>_INetGetSource ( $s_URL )however I tried to see the url but i have seen that after selecting the value from a dropdown the screen changes.So i need to capture the current webpage source that is presently displayed.I can t suppy a static urlAlso I cant get the whole text present between Participant ID and Announcement details when i ran the code on the relevent pageHere is the code$aArray1 = _StringBetween("","Participant ID","Announcement details") I dont want to search for a particular string but I want to get the text between two words on a webpage. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 9, 2007 Moderators Share Posted March 9, 2007 How do you think you get the text between two words? It's a string, you have the first word in the string you want to start at, and the ending part, and it captures everything between.... It does what you asked or better yet, it does what you explained (it being _StringBetween()). If you have to work with the current page/url, I'd suggest you look at the _IE.au3 and it's functions. And hope that your users aren't using firefox. GL. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
McGod Posted March 9, 2007 Share Posted March 9, 2007 IE.au3 [indent][center][u]Formerly Chip[/u][/center]~UDFs~[/indent][u]IRC.au3 - Allows you to connect to IRC ServersINetCon.au3 - Connects/Disconnects/Check Status of InternetHardware Key - Creates a unique hardware hashScriptComm - Allows you to communicate between scripts using WM_COPYDATA[/u][indent]~Programs~[/indent][indent]SimonAu3ForumsIRC Bot~Web Site~Web Autoit Example[/indent][indent][b][/b][/indent][u][/u] Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 9, 2007 Moderators Share Posted March 9, 2007 IE.au3LOL, that's twice I've done that this morning (putting an underscore in front of something that didn't need it). Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
UNO Posted March 9, 2007 Author Share Posted March 9, 2007 Hi, Following is my code #include <IE.au3> #include <String.au3> #include <array.au3> $oIE = _IEAttach ("General Information");the current version of the web page therefore attach to it $sText = _IEBodyReadText ($oIE) $aArray1 = _StringBetween($sText,"<span class=","</span><br>") MsgBox(0, "Body Text", $aArray1) ;_ArrayDisplay($aArray1, 'Default Search') _Array display is at all showing up and the script exits and whereas the msgbox is showing 0. Any ideas where i am going wrong.... Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 9, 2007 Moderators Share Posted March 9, 2007 It returns an array [0] is the first element of the array... just $aArray1 does nothing. MsgBox(0, "Body Text", $aArray1[0]) Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
_Kurt Posted March 9, 2007 Share Posted March 9, 2007 (edited) MsgBox(0, "Body Text", $aArray1[0])KurtEDIT: Damnit! Smoke_N, you always beat me to it! Edited March 9, 2007 by _Kurt Awaiting Diablo III.. Link to comment Share on other sites More sharing options...
UNO Posted March 9, 2007 Author Share Posted March 9, 2007 Got an error when i tried to run the script. It said "Error :Subscript used with non-Array variable" Here is the final code. #include <IE.au3> #include <String.au3> #include <array.au3> $oIE = _IEAttach ("General Information") $sText = _IEBodyReadText ($oIE) $aArray1 = _StringBetween($sText,"<span class=","</span><br>") MsgBox(0, "Body Text", $aArray1[0]) ;_ArrayDisplay($aArray1, 'Default Search') Where can i going wrong now Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 9, 2007 Moderators Share Posted March 9, 2007 How about checking how to use Arrays ... #include <IE.au3> #include <String.au3> #include <array.au3> $oIE = _IEAttach ("General Information") $sText = _IEBodyReadText ($oIE) $aArray1 = _StringBetween($sText,"<span class=","</span><br>") If IsArray($aArray1) Then MsgBox(0, "Body Text", $aArray1[0]) Else MsgBox(0, 'Empty', 'Nothing found') EndIf Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
UNO Posted March 9, 2007 Author Share Posted March 9, 2007 Hi smoke but i tried that too and it returned "Nothing found" When i went and viewed the source then it was there For your refernce pasting a part of the source <tr> <td> <br><span class="error"> * E4A345323 : Source Id is Mandatory</span><br> <br><span class="error"> * E4A545345 : Security Id is Mandatory</span><br> <br><span class="error"> * E4454200 : Confirmation Status is Mandatory</span><br> <script> Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 9, 2007 Moderators Share Posted March 9, 2007 Works fine for me when I copy what you have and do a FileRead() on it. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
_Kurt Posted March 9, 2007 Share Posted March 9, 2007 (edited) Sometimes I have trouble with _StringBetween, I usually: A) Make the before/after string more accurate B ) Make the before/after string less accurate C) Switch to StringRegExp.Perhaps try this:$RegExp = StringRegExp($Source, 'class="error">(.*?)</span>', 3) Msgbox(0,"",$RegExp[0]Remember that $RegExp[0] is only the first instance of the pattern. Therefore, if there's 2 of these "patterns" $RegExp[1] would be the second instance.Kurt Edited March 9, 2007 by _Kurt Awaiting Diablo III.. Link to comment Share on other sites More sharing options...
UNO Posted March 9, 2007 Author Share Posted March 9, 2007 then why am i not getting the code to work on my POC.so far i have succeeded in populating data from excel to the internal application of ours.i have also utilized the excel formulas to generate javascript funcion to populate input text boxes.this is the final thing i want to do i.e get the status which is present in 1 lines or multilines in span read... Looks like i am stuck and failed by 0.01% in getting the POC to work.Any ideas?I want my place to adopt AutoIT.Many are skecptical and many feel that it may be not be appropriate as it is a freeware.Some fear that they will evetually charge for this freeware in the near future(I dont think so personally after going thru this forum) 1 more issue i am facing........ Also I have trouble getting the Autoit to activate and send keys to the msgbox generated by alert javascript commang for eg typing this code on ur address bar will pop up an alert java script:alert("UNO"); but when i record and then try to play it back it skips sending enter to this alert. how can i resolve this too. Link to comment Share on other sites More sharing options...
UNO Posted March 9, 2007 Author Share Posted March 9, 2007 Thanks Kurt but i cant use the expression that u have provided coz when the data is uploaded successfully then i get another screen but with this code in source<br><span class="success"> * I445455 : Announcement added successfully</span><br> so i need the data between <br><span class=" and </span><br>(remember it may be multiline in case of failure.)I will then copy the span class data and then write to the adjaccent new column for status reporting to the excel data file using excelcom.udfstill searching for the answers.... Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 9, 2007 Moderators Share Posted March 9, 2007 @_Kurt, I made _StringBetween() to dummy it down for people really, those that understand StringRegExp() would more than likely not use _StringBetween() as they can be as precise as they like. @UNO You are making it difficult to help you. A suggestion would be, provide a link to something similar if not exact, post what you want to find, and maybe someone here can help you. When users ask for help, and make the people that like to help go out of their way to do so, the help either doesn't happen, or eventually stops. Being explicitly clear in details, step by step in what you are trying to achieve, and providing a snippet, the actual code itself, and all the tools necessary to help you is the best bet in fixing issues. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
UNO Posted March 9, 2007 Author Share Posted March 9, 2007 Smoke,I will see if i can find a similar site as the 1 i am working on is an intranet site so i cant get it up from net.i will post a similar site.i will look 4 it.i will summarize the problem.i automatically fill the data from excel to new internal site.then i click on submit.based on data i get different notification(they can be multiline also) like on the webpage*I445455 : Announcement added successfullyor i get error *E445455 : Field Name missing*E4434535455 : Field Id missing*E34577455 : Field Ph missinga small example that i can think of is the heading 4 this topic of mine on autoit forum2 User(s) are reading this topic (0 Guests and 0 Anonymous Users)then it displays name.(right now there are 2 names i.e UNO, GEOSoft)sometimes it many be none readers ....or sometimes it may be many readers... so it is similar to the status of who's reading this post.I need to copy that info.but 4 my case it embedded in the span tagfor eg<br><span class="error"> * E5Y50098 : Indicator is Mandatory</span><br>I hope i have thrown some light on this Link to comment Share on other sites More sharing options...
lenclstr746 Posted April 11, 2018 Share Posted April 11, 2018 u need to use _IEReadBodyHTML do not use _Inetget because ınetget get data from this url but ie read get from object html Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 11, 2018 Moderators Share Posted April 11, 2018 lenclstr746, Did you realise that the post above yours dates from over 11 years ago? And that the poster has not been active since nearly that long ago? Please do not necro-post like this in future. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
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