Skip to content

Instantly share code, notes, and snippets.

@turbo
Created May 15, 2016 15:38
Show Gist options
  • Select an option

  • Save turbo/3cb016bff609ea6169144a21b38714fd to your computer and use it in GitHub Desktop.

Select an option

Save turbo/3cb016bff609ea6169144a21b38714fd to your computer and use it in GitHub Desktop.
Parse stackexchange chat logs
#include <IE.au3>
ConsoleWrite(_ParseMsgLog("http://chat.stackexchange.com/transcript/240/6-9"))
Func _ParseMsgLog($sURL)
Local $oIE = _IECreate($sURL, 0, 0, 1, 0)
Local $sOutput = ""
; Iterate over all <div>s
For $eachDiv In _IETagNameGetCollection($oIE, "div")
With $eachDiv
; Parse username and user ID from div
If .className == "username" Then
$aData = StringRegExp(.innerHTML, 'href="(.+?)">(.+?)<\/a>', 3)
$sOutput &= "[ " & $aData[1] & " (" & $aData[0] & ") ]" & @LF
EndIf
; Parse message content, skip everything else
ContinueLoop .className <> "content"
$sOutput &= StringStripWS(.innerHTML, 3) & @LF & @LF
EndWith
Next
_IEQuit($oIE)
Return $sOutput
EndFunc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment