What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general.

Learn more

PRTG Network Monitor

Intuitive to Use. Easy to manage.
More than 500,000 users rely on Paessler PRTG every day. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free Download

Top Tags


View all Tags

How can I re-use data from the HTML code of a webpage in Webserver Stress Tool?

Votes:

0

I want to reuse HTML code (e.g. session ID) for subsequent requests.

html script webserver-stress-tool

Created on Feb 24, 2010 9:14:22 AM by  Daniel Zobel [Product Manager]



1 Reply

Accepted Answer

Votes:

0

Reusing data from the HTML code of a webpage (e.g. session id) for subsequent requests

This script shows how to read some data from the HTML of a page and the use this data in subsequent requests.

Sample Code

' ===============================================================
' Webserver Stress Tool V7 *** Sample Script for Reusing a Token
' ===============================================================
' Requires Webserver Stress Tool 7.0.2 or later

Sub OnBeforeClick

if data.clickcount=0 then data.url="https://walldorf.paessler.com" end if
if data.clickcount=1 then data.url="https://walldorf.paessler.com/?test="+data.token end if
data.log="Preparing click #"+inttostr(data.clickcount+1)+" of user #"+inttostr(data.usernumber+1)

end Sub

Sub OnAfterClick
data.log=""
end sub

Sub OnbeforeRequest
data.log=""
end sub


Sub OnAfterRequest

if data.clickcount=0 then 'we only look in the HTML of the first click for our tags
if data.requestcount=0 then 'we only look in the HTML of the first request of the first click for our tags

tagbefore="<title>"
tagafter="</title>" 'our tag/token delimiters

if pos(tagbefore,request.html)>0 then
if pos(tagafter,request.html)>0 then
tagbegin=pos(tagbefore,request.html)+length(tagbefore)
taglength=pos(tagafter,request.html)-tagbegin
mytag=copy(request.html,tagbegin,taglength)
data.log="FOUND TOKEN: '"+mytag+"'"
data.token=mytag
else
data.log="Closing Token not found ("+tagafter+") in request number "+inttostr(data.requestcount)+" with resultcode "+inttostr(request.resultcode)+" ("+request.result+")"
end if
else
data.log="Opening Token not found ("+tagbefore+") in request number "+inttostr(data.requestcount)+" with resultcode "+inttostr(request.resultcode)+" ("+request.result+")"
end if

end if
end if

end sub

Created on Feb 24, 2010 9:15:36 AM by  Daniel Zobel [Product Manager]




Disclaimer: The information in the Paessler Knowledge Base comes without warranty of any kind. Use at your own risk. Before applying any instructions please exercise proper system administrator housekeeping. You must make sure that a proper backup of all your data is available.