Converting a PHP to ASP VBScript
Hello,
Can anyone please help me on converting the following PHP to asp VBScript. Here is the code:
<?
// PHP example
function GetCurlPage ($pageSpec)
{
$ch = curl_init($pageSpec);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$tmp = curl_exec ($ch);
curl_close ($ch);
$tmp = preg_replace('/(?s)<meta http-equiv="Expires"[^>]*>/i', '', $tmp);
return $tmp;
}
$suffixes=urlencode("com.au|com"); // enter list of suffixes to check
$domain = "testarama"; // enter the keyword of the domain ie without a suffix
$fuzzysearch = "0" ; // 0 is off 1 is on
$returnUrl=""; // enter a url to post return values to
$url = "https://ssl.twoplums.com.au/tppautomation/test/availability/check.php?domain=" .
$domain . "&suffixes=" . $suffixes . "&fuzzysearch=" . $fuzzysearch;
$output = GetCurlPage("$url");
print $output;
?>
Here is what i started and i know i was way off track, so i stopped
<%
Function GetCurlPage (Dim pageSpec)
Dim ch = curl_init (Dim pageSpec)
%>
If i can please get some assistance.
Thank you
bja888 (not verified) posted this at 00:47 — 16th November 2005.
They have: 5,633 posts
Joined: Jan 1970
Im a asp guru but I know not VB. I'm quite curious though... Why would you want to go from php to asp?
Abhishek Reddy posted this at 07:12 — 16th November 2005.
He has: 3,348 posts
Joined: Jul 2001
Probably your biggest challenge here is finding ASP/VB analogues of the PHP curl bindings, and maybe also using that bit of Perl regex. I do not recall if and how ASP/VB supports either of these; curl packages are available for Win32, but does ASP/VB ship with it?
Time to hit Google.
(Let me know if the above didn't make any sense, I'm not sure how confident you are with this.)
chrishirst posted this at 08:19 — 16th November 2005.
He has: 379 posts
Joined: Apr 2005
you will need to use the XMLHTTP Object to get the page content with ASP;
This will return the page source if it gets a 200 response otherwise it will return the error code.
function GetPageCode(strURL)
Response.Buffer = True
Dim xml
Set xml = Server.CreateObject("Microsoft.XMLHTTP")
xml.Open "GET", strURL, False
xml.setRequestHeader "User-Agent", ' insert your own user agent string here
xml.Send
if xml.status = 200 then
GetPageCode = xml.responseText
else
GetPageCode = cstr(xml.status) & " (" & xml.StatusText & ")"
end if
Set xml = Nothing
end function
Chris
Indifference will be the downfall of mankind, but who cares?
Venue Capacity Monitoring
Code Samples
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.