Faleira Posted October 16, 2005 Share Posted October 16, 2005 I have a text file, that i have my macro copy paste the html souce code of a site to. There this part of the window that changes from time to time. I want it so that the macro logs it into a text file or maybe an html file. (the thing i want it ti 'log' is more like a tagboard type of thing) i have it so that the macro performs a stringinstr to find out where the code of where i want to start tagging is. But i'm not too sure how i would have it so that i could copy from, say "this position to this position" and then filewrite it... sorry if wat i said is kinda confusing... [quote]If whenever you feel small, useless, offended, depressed, and just generally upset always remember......you were once the fastest and most vicious sperm out of hundreds of millions![/quote] Link to comment Share on other sites More sharing options...
BigDod Posted October 16, 2005 Share Posted October 16, 2005 I have a text file, that i have my macro copy paste the html souce code of a site to. There this part of the window that changes from time to time. I want it so that the macro logs it into a text file or maybe an html file. (the thing i want it ti 'log' is more like a tagboard type of thing) i have it so that the macro performs a stringinstr to find out where the code of where i want to start tagging is. But i'm not too sure how i would have it so that i could copy from, say "this position to this position" and then filewrite it...sorry if wat i said is kinda confusing...Perhaps you could use StringMid if you knew the starting point or some of the other string functions depending on which part of the string you wish to keep/strip. If this does not help it may be better if you posted some code along with a couple samples of what you want to log. Time you enjoyed wasting is not wasted time ......T.S. Elliot Suspense is worse than disappointment................Robert Burns God help the man who won't help himself, because no-one else will...........My Grandmother Link to comment Share on other sites More sharing options...
bluebearr Posted October 16, 2005 Share Posted October 16, 2005 i have it so that the macro performs a stringinstr to find out where the code of where i want to start tagging isSince the length of the text that you want probably changes, you'll need some way to tag where the desired text ends, then use that to snip the text.For example, look at the source of this page: http://www.rbc.org/odb/odb.shtml. If I wanted to grab the little story, and nothing else, I'd first note that just before the story is the phrase "Bible In One Year:" which probably doesn't change every day. I can use StringInStr to find where that is, then use StringMid to remove everything before. Now that I have this shorter string I can see that the story starts after an <img> tag, and ends just before a <center> tag. I can use StringInStr and StringMid to chop the string to include what is between.Here is some sample code. Hopefully it will help you with your project:#include <File.au3> $SrcFile = _TempFile() InetGet("http://www.rbc.org/odb/odb.shtml", $SrcFile) FileOpen($SrcFile, 0) $PageSource = FileRead($SrcFile, FileGetSize($SrcFile)) FileClose($SrcFile) FileDelete($SrcFile) ; Figure out where the story is $start = StringInStr($PageSource, "Bible In One Year") $story = StringMid($PageSource, $start, StringLen($PageSource) ) $story = StringMid($story, StringInStr($story, "<img"), StringLen($story) ); start image tag $story = StringMid($story, StringInStr($story, ">") + 1, StringLen($story) ); end image tag $end = StringInStr($story, "<center>") $story = StringMid($story, 1, $end - 1) ; Minor cleanup $story = StringReplace( $story, "<p>", ""); replace <p> tag $story = StringReplace($story, "", ""); replace long dash MsgBox(0, "Story of the day", $story) BlueBearrOddly enough, this is what I do for fun. Link to comment Share on other sites More sharing options...
Faleira Posted October 16, 2005 Author Share Posted October 16, 2005 (edited) thankx, that was precisely wat i needed ^^ Edited October 16, 2005 by Faleira [quote]If whenever you feel small, useless, offended, depressed, and just generally upset always remember......you were once the fastest and most vicious sperm out of hundreds of millions![/quote] 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