Sample code for 30+ languages & platforms
Xbase++

Example: Http.ExtractMetaRefreshUrl method

Demonstrates the ExtractMetaRefreshUrl method.

Chilkat Xbase++ Downloads

Xbase++
LOCAL nSuccess
LOCAL oHttp
LOCAL oSb
LOCAL nBCrlf
LOCAL cUrl

nSuccess := 0

oHttp := CreateObject("Chilkat.Http")

//  Sample HTML with a META refresh.

//  <!DOCTYPE html>
//  <html lang="en">
//  <head>
//    <meta charset="utf-8" />
//    <meta http-equiv="refresh" content="5; url=https://example.com" />
//    <title>Meta Refresh Redirect</title>
//  </head>
//  <body>
//    <p>Redirecting to example.com in 5 seconds�</p>
//  </body>
//  </html>

oSb := CreateObject("Chilkat.StringBuilder")
nBCrlf := 1
oSb:AppendLine("<!DOCTYPE html>", nBCrlf)
oSb:AppendLine('<html lang="en">', nBCrlf)
oSb:AppendLine("<head>", nBCrlf)
oSb:AppendLine('  <meta charset="utf-8" />', nBCrlf)
oSb:AppendLine('  <meta http-equiv="refresh" content="5; url=https://example.com" />', nBCrlf)
oSb:AppendLine("  <title>Meta Refresh Redirect</title>", nBCrlf)
oSb:AppendLine("</head>", nBCrlf)
oSb:AppendLine("<body>", nBCrlf)
oSb:AppendLine("  <p>Redirecting to example.com in 5 seconds�</p>", nBCrlf)
oSb:AppendLine("</body>", nBCrlf)
oSb:AppendLine("</html>", nBCrlf)

cUrl := oHttp:ExtractMetaRefreshUrl(oSb:GetAsString())
IF (oHttp:LastMethodSuccess == 0)
    ? "The HTML has no META refresh tag."
ELSE
    ? "META refresh URL: " + cUrl
ENDIF

oHttp:destroy()
oSb:destroy()