View Single Post
  #5 (permalink)  
Old 3rd May, 2005, 04:26 PM
danrok's Avatar
danrok danrok is offline
AOA Staff
 
Join Date: March 2003
Location: Great Britain
Posts: 18,917

Here's the VBScript which will get the latest threads from AOA and write them in to a text file.

To use this code, copy and paste it into a text file called "aoa_threads.vbs".

Use the Windows scheduler to run the script every 5 mins or so.

Quote:
' This script will get the latest threads from AOA Forums
' the thread titles will be written in to a text file.
' Code last updated 20050503

'variables

Dim regEx

On Error Resume Next

' Set filenames and URLs

Const StatusFile ="aoa_status.txt"
Const ThreadsFile = "aoa_new_threads.txt"
Const pageURL ="http://www.aoaforums.com/forum/search.php?do=getnew"

set http = createobject("microsoft.xmlhttp")
Http.open "GET", PageURL, false
Http.send
strng = Http.responsetext

' Create the output file
Set fs = CreateObject("Scripting.FileSystemObject")
Set StatusoutFile = fs.CreateTextFile(StatusFile, True)

If strng <> "" then
' Create the output file
Set fs = CreateObject("Scripting.FileSystemObject")
Set ThreadsoutFile = fs.CreateTextFile(ThreadsFile, True)
' Make sure the output is formatted with correct quotes and ampersands
strng = replace(strng,"&quot;",Chr(34))
strng = replace(strng,"&amp;",Chr(38))

' Find the thread titles

Set regEx = New RegExp
regEx.Global = True
regEx.Pattern = "<strong>(.*?)</strong></a>"

Set Matches = regEx.Execute(strng)

' Write the text lines to file

For Each Match in Matches
Threadsoutfile.write match.SubMatches(0)
ThreadsoutFile.WriteLine
Next
' Close the Threads file
ThreadsoutFile.close
Statusoutfile.write "<c:lime>on-line</c>"
StatusoutFile.WriteLine
else
Statusoutfile.write "<c:red>off-line</c>"
StatusoutFile.WriteLine
end if

' Close status file
StatusoutFile.close
You can display the contents of the text file using CoolMon 1.

You'll need to put the following lines or similar into the Display Options in CM1.

Quote:
<c:yellow><b>AOA Latest Threads</b></c> <NAME=FILEDATA FORMAT="aoa_status.txt,1">
<NAME=FILEDATA FORMAT="aoa_new_threads.txt,2">
<NAME=FILEDATA FORMAT="aoa_new_threads.txt,3">
<NAME=FILEDATA FORMAT="aoa_new_threads.txt,4">
<NAME=FILEDATA FORMAT="aoa_new_threads.txt,5">
<NAME=FILEDATA FORMAT="aoa_new_threads.txt,6">
<NAME=FILEDATA FORMAT="aoa_new_threads.txt,7">
<NAME=FILEDATA FORMAT="aoa_new_threads.txt,8">
<NAME=FILEDATA FORMAT="aoa_new_threads.txt,9">
<NAME=FILEDATA FORMAT="aoa_new_threads.txt,10">
<NAME=FILEDATA FORMAT="aoa_new_threads.txt,11">
Attached Images
 
__________________
Desktop PC: AMD FX-8370E / Asus M5A99X Evo R2.0 Motherboard / 16GB DDR3 RAM / GeForce GTX 970
AOA Team fah

Last edited by danrok; 3rd May, 2005 at 04:34 PM.
Reply With Quote