DigitalLocksmith Posted June 8, 2007 Posted June 8, 2007 I've gotten this far from extracting this line out of html source and reading it into a text file. I need to extract the numbers 49 and 429 into seperate variables so I can run a file or compare them to something else if they change to any other number. Basically I'm getting an error and when I take the quotes out it works, so that's obviously the issue. Any ideas how I can work around this? <b>Displaying<span class="redtext"> 49 </span>of<span class="redtext"> 429 </span>comments Here's my example code.CODE$var = StringMid(" <b>Displaying<span class="redtext"> 49 </span>of<span class="redtext"> 429 </span>comments ", 3, 2) MsgBox(0, "2 chars extracted from position 3 are:", $var)
DigitalLocksmith Posted June 8, 2007 Author Posted June 8, 2007 Scratch that...It would be awesome if I could extract that comment number to a variable without ever writing to a text file...What am I doing wrong?CODE#include <INet.au3> $comments = "Displaying" $file = FileOpen("test.txt", 1) $linetext = "line.txt" $lineread = FileOpen("line.txt", 0) $profile = "www.myspace.com/tom" $source = _INetGetSource ($profile) FileWrite($file , $source) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf FileClose($file) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; $file = FileOpen("test.txt", 0) While 1 $line = FileReadLine($file) If @error = -1 Then ExitLoop if StringInStr(" "&$line,$comments)>0 then FileWrite($linetext, $line) WEnd ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; FileClose($file) $comnumber = $linetext $time = StringSplit($comnumber, " ") $time = $time[2] MsgBox(4096, "Result", $time)
Xenobiologist Posted June 8, 2007 Posted June 8, 2007 Hi, use _IngetSource and then _StringBetween. No do not need to save it to file. So long, Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times
DigitalLocksmith Posted June 8, 2007 Author Posted June 8, 2007 (edited) Here's the whole source. Haven't got it working without writing to a file, but I'll figure it out eventually. I'm stumped for now. My goal once I can get it working is to monitor and notify me everytime anyone on my friends list has new comments on their myspace, or something changes on their profile like the headline. I'd just compare the whole page source to the last one logged, but because of the ads and timestamp crap the source changes everytime you pull it. The line that displays how many comments you have is perfect because it's always in the same line in the page source, but the number changes so you can check it for changes.CODE #include <INet.au3> $comments = "Displaying" $file = FileOpen("test.txt", 1) $linetext = "line.txt" $lineread = FileOpen("line.txt", 0) $profile = "www.myspace.com/tom" $source = _INetGetSource ($profile) FileWrite($file , $source) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf FileClose($file) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; $file = FileOpen("test.txt", 0) While 1 $line = FileReadLine($file) If @error = -1 Then ExitLoop if StringInStr(" "&$line,$comments)>0 then FileWrite($linetext, $line) WEnd ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Output to msgbox returning blank FileClose($file) $var = StringMid($linetext, 100, 4) MsgBox(0, "comment count is:", $var) It only works when manually entered instead of using a variable like this, so I guess it can't parse the quotes from a variable. CODE$linetext = (" <b>Displaying<span class=""redtext""> 49 </span>of<span class=""redtext""> 429 </span>comments ") $var = StringMid($linetext, 100, 4) MsgBox(0, "2 chars extracted from position 3 are:", $var) Edited June 8, 2007 by DigitalLocksmith
Xenobiologist Posted June 8, 2007 Posted June 8, 2007 Hi, #include<Array.au3> #include<String.au3> $values = _StringBetween(_INetGetSource('your url'), 'class="redtext">', '</span>') _ArrayDisplay($values) So long, Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times
DigitalLocksmith Posted June 8, 2007 Author Posted June 8, 2007 Jeez that would be a heck of a lot easier than what I'm doing, but I'm getting an unknown function name error at _InetGetSource for some reason....syntax?
PsaltyDS Posted June 8, 2007 Posted June 8, 2007 Jeez that would be a heck of a lot easier than what I'm doing, but I'm getting an unknown function name error at _InetGetSource for some reason....syntax? You need: #include <INet.au3> Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Xenobiologist Posted June 8, 2007 Posted June 8, 2007 Hi, have a look at my organize includes script in my sig, so needn't to care about includes any more. :-) So long, Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times
DigitalLocksmith Posted June 8, 2007 Author Posted June 8, 2007 (edited) Yeah, my bad....forgot the #include....It's 5:39am here...Thanks a ton mega...I was making it waaaaay harder than it is. You're the man. Edited June 8, 2007 by DigitalLocksmith
DigitalLocksmith Posted June 8, 2007 Author Posted June 8, 2007 Ok, forgive me and I promise that this will be the last question about this but I'm really trying to wrap my head around autoit3. (used to use v2 a lot waaaay back in the day) What do I need to do to display the value to a msgbox like this? Is $values blank unless you use _ArrayDisplay? CODE#include <INet.au3> #include<Array.au3> #include<String.au3> $profile = 'www.myspace.com/tom' $source = _INetGetSource ($profile) $values = _StringBetween($source, 'class="redtext">', '</span>' ) MsgBox(0, "Comment count is:", $values)
Xenobiologist Posted June 8, 2007 Posted June 8, 2007 (edited) Hi, no problem: #include <INet.au3> #include<String.au3> $profile = 'www.myspace.com/tom' $values = _StringBetween(_INetGetSource($profile), 'class="redtext">', '</span>') For $i = 0 To UBound($values) - 1 ; maybe $i = 1 if you needn't the count. MsgBox(0, "Comment count is:", $values[$i]) Next So long, Mega Edited June 8, 2007 by th.meger Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times
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