RAMMRODD Posted September 23, 2011 Share Posted September 23, 2011 I'm trying to gather information from a table, but **_IETableGetCollection** doesnt seem to work for me. I'm trying to get whats between tags. <span class="sort-data hide">object</span> I tried _stringbetween but I think the quotes messed it up. So I tried singles ( ' ) but all it would send me is "0" . Is string between what I want? #Include <String.au3> #include <Array.au3> $file = FileOpen("test.txt", 0) ; Check if file opened for reading OK If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf ;~ ; Read in 1 character at a time until the EOF is reached While 1 $chars = FileRead($file) $b=_stringbetween($chars,"<strong>","</strong>") If @error = -1 Then ExitLoop _ArrayDisplay($b) ; MsgBox(0, "Char read:", _arraytostring($b,@tab,0,0)) Wend In this example I got <strong> and </strong> to display into an array, but I couldn't seem to get just the first instance of the tag. Any help would be great. Chad PS the script I started from was an example from here, I just chopped it up. I dont claim this as 100% me. Link to comment Share on other sites More sharing options...
Beege Posted September 23, 2011 Share Posted September 23, 2011 In this example I got <strong> and </strong> to display into an arrayIf your searching for whats in between <strong> and </strong>, <strong> and </strong> should not be showing up in the array. Normally the first instance would be in $array[0], the second in $array[1] and so on. Single quotes or double quotes wouldnt matter in this case. They might if for example there was a quote in the search string like <stro'ng>, Can you post a portion of text your prasing from test.txt? Assembly Code: fasmg . fasm . BmpSearch . Au3 Syntax Highlighter . Bounce Multithreading Example . IDispatchASMUDFs: Explorer Frame . ITaskBarList . Scrolling Line Graph . Tray Icon Bar Graph . Explorer Listview . Wiimote . WinSnap . Flicker Free Labels . iTunesPrograms: Ftp Explorer . Snipster . Network Meter . Resistance Calculator Link to comment Share on other sites More sharing options...
RAMMRODD Posted September 23, 2011 Author Share Posted September 23, 2011 (edited) When I saidI got <strong> and </strong> to display into an array I actually didnt mean those words (my bad) I meant that I got what was between them to display. Example from test.txt: <strong>Cloth</strong><br /> <a href="/wool">Wool</a> <span class="sort-data hide">1 Wool</span> So I'd be trying to get "cloth","wool" and "1 wool" out of that clip. But when I tried doing between "<span class="sort-data hide">" and "</span>" it throws me a "0". The main idea would be to have a whole page of these and be able to group them together. This example would be to finish with "Cloth-Wool: 1 Wool" and the next one may have similar tags that need to be "deciphered". Thanks for the quick response. Edit After thought: would <span*> work in some way? Just eliminating the quote in quote? Edited September 23, 2011 by RAMMRODD Link to comment Share on other sites More sharing options...
Beege Posted September 23, 2011 Share Posted September 23, 2011 (edited) All good. I was hoping that was a typo. Anytime your beginning or end search strings have a double quote in them, enclose it with single quotes. If it has a single quote in it, then enclose it with double quotes. Below works, but prasing a large page vs one string can change that so see what happens. #include <string.au3> #include <array.au3> $string = '<strong>Cloth</strong><br /> <a href="/wool">Wool</a> <span class="sort-data hide">1 Wool</span>' $wool = _StringBetween($string, '<a href="/wool">', '</a>') _ArrayDisplay($wool) $1wool = _StringBetween($string, '<span class="sort-data hide">', '</span>') _ArrayDisplay($1wool) edit: damn i cant type Edited September 23, 2011 by Beege Assembly Code: fasmg . fasm . BmpSearch . Au3 Syntax Highlighter . Bounce Multithreading Example . IDispatchASMUDFs: Explorer Frame . ITaskBarList . Scrolling Line Graph . Tray Icon Bar Graph . Explorer Listview . Wiimote . WinSnap . Flicker Free Labels . iTunesPrograms: Ftp Explorer . Snipster . Network Meter . Resistance Calculator Link to comment Share on other sites More sharing options...
RAMMRODD Posted September 24, 2011 Author Share Posted September 24, 2011 Thanks so much. Got it working, much appreciated. Until next time :-) Link to comment Share on other sites More sharing options...
RAMMRODD Posted September 25, 2011 Author Share Posted September 25, 2011 Wouldn't it be possible to put these into an array? So I could get a print out of each "group", So if there were like 15 of these examples it could print #1 "cloth","wool" and "1 wool" #2 "cloth","satin" and "1 satin" #3 etc Maybe an array isn't the right term, I suck at arrays and why they'd be used. A loop of some sort maybe? Link to comment Share on other sites More sharing options...
czardas Posted September 26, 2011 Share Posted September 26, 2011 (edited) This code can be made shorter by using loops inside loops (and probably a few other tricks), but I thought it might be easier to comprehend if I left it as it is. #include <Array.au3> ; For _ArrayDisplay Dim $s_HTML = _ '<strong>Cloth</strong><br /> <a href="/wool">Wool</a> <span class="sort-data hide">1 Wool</span> ' & _ '<strong>Cloth</strong><br /> <a href="/satin">Satin</a> <span class="sort-data hide">1 Satin</span> ' & _ '<strong>Cloth</strong><br /> <a href="/linen">Linen</a> <span class="sort-data hide">1 Linen</span> ' Dim $aRet = StringRegExp($s_HTML, '>[^<]+</st', 3) Dim $aArray[Ubound($aRet)][3] For $i = 0 To Ubound($aRet) -1 $aRet[$i] = StringTrimRight($aRet[$i], 4) $aArray[$i][0] = StringTrimLeft($aRet[$i], 1) Next $aRet = StringRegExp($s_HTML, '>[^<]+</a>', 3) For $i = 0 To Ubound($aRet) -1 $aRet[$i] = StringTrimRight($aRet[$i], 4) $aArray[$i][1] = StringTrimLeft($aRet[$i], 1) Next $aRet = StringRegExp($s_HTML, '>[^<]+</sp', 3) For $i = 0 To Ubound($aRet) -1 $aRet[$i] = StringTrimRight($aRet[$i], 4) $aArray[$i][2] = StringTrimLeft($aRet[$i], 1) Next _ArrayDisplay($aArray) Edited September 26, 2011 by czardas operator64 ArrayWorkshop 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