ScriptBasic
February 09, 2012, 06:39:05 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Registration Disabled Send an e-mail to support @ scriptbasic.org to request a membership to this forum. (include desired forum name)
 
   Home   Wiki Help Search Login Register  
Pages: [1]
  Print  
Author Topic: WEBGET - Browser based Curl Example  (Read 2165 times)
support
Administrator
*****
Posts: 369


« on: May 17, 2006, 04:14:30 PM »

This example Curl program will retrieve the source HTML of the URL you submit. IE doesn't work with default security settings and the 'MIME Sniffing" feature needs to be disabled so the file attribute is used for MIME determination like the other browsers. MSDN Reference

http://www.scriptbasic.org/curl.html

Code:

*** getweb.bas ***

#!/usr/bin/scriba -c

INCLUDE cgi.bas
INCLUDE curl.bas

OPTION cgi$Method cgi::Post or cgi::Get

this_url = cgi::PostParam("geturl")

CURL = curl::init()
curl::option CURL,"URL",this_url
curl::option CURL,"FILE","/var/www/vhosts/scriptbasic.org/httpdocs/pagedump.txt"
curl::perform CURL
curl::finish CURL

cgi::Header 302,""
PRINT "Location: /pagedump.txt\n"
cgi::FinishHeader

END


*** curl.html ***

<html>
<head>
<title>ScriptBasic WebGet</title>
</head>
<body>
<h1>Curl Example</h1>

Enter URL to retrieve:

<form method="post" action="/cgi-bin/getweb.bas">
  <input type="text" name="geturl" size=40>
  <input type="submit" value="Get Page">
</form>
</body>
</html>
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!