If your "random data" always starts with </div> like posts would, you can do:
%fixedData = getSubStr(%rawData, 0, strPos(%rawData, "</div>"));
If you're truly running an IIS then you should be able to modify the PHP code to put a tag on each post to signify where the post ends. Or you can fix your PHP code to output those tags on a different line, thus resolving the problem completely for the data won't be there in the first place. I don't see why it doesn't do this.