wazer Posted October 11, 2015 Share Posted October 11, 2015 Hello, I wanted to create a personal reddit news tag for internal use and to become better with autoit.I would really appreciate some other eyes on my pretty much search copy code I have found various places in the forums(I know its not clean or pretty, maybe you can help?)What can I/We do to make it more simple and maybe faster, any help?Also I'm having a problem deleting lines that pretty much will become dynamic after each change logThe codeexpandcollapse popup#include <INet.au3> #include <String.au3> ;File Delete FileDelete("c:\test.txt") sleep(100) ;Get News feed exploded by php script $version =_INetGetSource("http://wazer.dk/rod/csgo_version_changelog.php") ;Get csgo version number from API $csversion =_INetGetSource("http://wazer.dk/rod/csgo_version.php") $csversion = StringRegExpReplace($csversion,"^(\r\n)+|(\r\n)+$","") ; Remove blank lines at start or end of data ;Read Changelog Date between 'for' AND '</a>' $aArray1 = _StringBetween($version, 'for', '</a>') ;Read Changelog LINK between "'<a href="' AND '">' $aArray2 = _StringBetween($version, '<a href="', '">') ;Generate First Line with all the above variables $first = ("Counter-Strike: Global Offensive update v." & $csversion & $aArray1[0] & @CRLF & @CRLF & "Via [CS:GO Blog:](" & $aArray2[0] & ")" & @CRLF & @CRLF) ;Generate File 1st line FileWrite("c:\test.txt", $first) ;Search and Add different reddit tags(like bbcode) $aSearch = StringSplit("[", ",", 2) $aReplace = StringSplit("**[** ", ",", 2) $sStr = $version For $i = 0 To Ubound($aSearch) -1 $sStr = StringReplace($sStr, $aSearch[$i], $aReplace[$i]) $bSearch = StringSplit("]", ",", 2) $bReplace = StringSplit(" **]** ", ",", 2) For $i = 0 To Ubound($bSearch) -1 $sStr = StringReplace($sStr, $bSearch[$i], $bReplace[$i]) $cSearch = StringSplit("–", ",", 2) $cReplace = StringSplit("* ", ",", 2) For $i = 0 To Ubound($cSearch) -1 $sStr = StringReplace($sStr, $cSearch[$i], $cReplace[$i]) next next next ;Clean up code output for different charecters, spaces and what not! $sStr = StringRegExpReplace($sStr,"\n( |\t)+",@LF) ; Remove whitespace at the start of lines $sStr = StringRegExpReplace($sStr,"(?s)<[^>]*?>",@CRLF) ; Remove < and > and all the text in between $sStr = StringRegExpReplace($sStr,"(\r\n)+",@CRLF) ; Remove blank lines in data $sStr = StringRegExpReplace($sStr,"^(\r\n)+|(\r\n)+$","") ; Remove blank lines at start or end of data ;Check console if its OK consolewrite($sStr) ;Generete Final output. FileWrite("c:\test.txt", $sStr) Todays output if we take the current changelog for CSGO news feed if we run the script as it is now. Counter-Strike: Global Offensive update v.13506 10/8/2015 Via [CS:GO Blog:](http://blog.counter-strike.net/index.php/2015/10/12739/) Release Notes for 10/8/2015 8 Oct 2015 - **[** GAMEPLAY **]** * Adjusted player flashbang reaction animation so the raised arm matches first-person blindness. **[** MISC **]** * Players will no longer get the default weapon in a loadout slot when the game server loses connection to the GC. * Bots no longer get stuck in a crab-walk after a rare failure during crouch-jump. **[** MAPS **]** Cobblestone * Fixed some areas where players could look through model backfacesNow i would like to get line 6 and 8 totally deleted/whipped out.Release Notes for 10/8/20158 Oct 2015 - But the thing is they will change when a new changelog comes out.So what can I do there? Kindly regards. JohnOne 1 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