Manic Posted June 29, 2011 Share Posted June 29, 2011 Hey all!I'm trying to search for a string within an HTML document. The problem is that when I am searching for this string, the string has double quotes in it already. I've read the syntax for quoting in Autoit, how to use single-quotes around a string with double-quotes in it, and none of the methods have worked. I can search the html source code and find the exact string I am looking for (CTRL+F), and then I copy that string into my AutoIt script, and tell it to search for that string. This doesn't seem to work unless I tell my script to search for a string without any double quotes (but that's not what I want).$oIE = _IEAttach("Sample Browser window that is already open") $oBodyRead = _IEBodyReadHTML ($oIE) $FIRST = StringInStr ($oBodyRead, '<h1 class="sampleText" id="sometext_', 0, 1, 1) MsgBox (1, "test", "result: " & $FIRST)<h1 class="sampleText" id="sometext_35362"><span>353</span> Some text here</h1>Thoughts? Link to comment Share on other sites More sharing options...
Realm Posted June 29, 2011 Share Posted June 29, 2011 This Works for me$string = '<h1 class="sampleText" id="sometext_35362"><span>353</span> Some text here</h1>' $FIRST = StringInStr ($string, '<h1 class="sampleText" id="sometext_', 0, 1, 1) MsgBox (1, "test", "result: " & $FIRST)What browser are you using to get your source to check for?If your using anything other than Internet Explorer to get your test source from, read this postIt explains basically how each browser will deliver the source in different formats and encoding.Realm My Contributions: Unix Timestamp: Calculate Unix time, or seconds since Epoch, accounting for your local timezone and daylight savings time. RegEdit Jumper: A Small & Simple interface based on Yashied's Reg Jumper Function, for searching Hives in your registry. Link to comment Share on other sites More sharing options...
Manic Posted June 29, 2011 Author Share Posted June 29, 2011 (edited) Hey Realm, I noticed that you defined a string with text in it (I wish it were that easy!). In my code, I'm getting the HTML from the page and searching for a TAG within the HTML, and this TAG has elements (ex: <tr name="hello">. Do you know what I mean? $oBodyRead = _IEBodyReadHTML ($oIE) <-- this line grabs the html that I want to read (just making sure we're on the same page) Also that's a good post. I'm using IExplorer to check the source. Manic Edit: clarification Edited June 29, 2011 by Manic Link to comment Share on other sites More sharing options...
Realm Posted June 29, 2011 Share Posted June 29, 2011 (edited) Manic, I sorta know what your talking about. If maybe I knew the website, and exactly what it is that your trying to obtain, I could help better. I'm not sure what your really trying to grab. StringinStr() is a True/False function, it will only return 1 for true, or 0 for false. So if your just trying to find if a given text exists in the string, then this is good. If you looking to grab information from a string, try StringRegEx() or _StringBetween() If I'm still offbase, share the website and what object your trying to interact with or get, and I or someone here will be happy to help. Realm Edit: A few functions more including IE Tags. $aTags = _StringBetween('<tr name="hello">','<tr name="','">') $oElements = _IETagNameAllGetCollection ($oIE) $oInputs = _IETagNameGetCollection ($oIE, "input") Edited June 29, 2011 by Realm My Contributions: Unix Timestamp: Calculate Unix time, or seconds since Epoch, accounting for your local timezone and daylight savings time. RegEdit Jumper: A Small & Simple interface based on Yashied's Reg Jumper Function, for searching Hives in your registry. 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