Executing curl from Javascript?

Is there a way to execute curl from Javascript? Thanks.

  • Convert curl GET to javascript fetch
  • How to output DOM after all javascript loaded?
  • Automatically log in on another website at the click of a button - cURL or Javascript?
  • Unexpected End of Input - curl JSON on Express/Node App
  • PHP cURL download progress using jquery
  • Does the curl library execute javascript inside pages?
  • Automatically log in on another website at the click of a button - cURL or Javascript?
  • Activating google analytics using curl?
  • HTTP file download with Javascript
  • Google safe browsing API: unable to download list
  • Perform curl request in javascript?
  • How to download in bash from zippyshare?
  • 3 Solutions collect form web for “Executing curl from Javascript?”

    Nope. You’ll need to look at using Ajax/XMLHttpRequest instead. http://en.wikipedia.org/wiki/Ajax_%28programming%29

    It depends on what curl you are talking about. You are probably asking about cURL, but if you are asking about the Curl programming language, then the answer is yes. You can invoke Curl methods on an object in an embedded Curl subapplet using the applet_invoke method. There are examples of this in the subapplet examples that are included in the Curl Developer’s Guide.

    It depends of which environment is running javascript, if you mean from the browser, nop, it’s not possible.

    But if it’s from Node.js, yes it’s possible using native modules. Take a look at: https://github.com/JCMais/node-libcurl

    Code example:

    var Curl = require( 'node-libcurl' ).Curl;
    
    var curl = new Curl();
    
    curl.setOpt( 'URL', 'http://www.google.com' );
    curl.setOpt( 'FOLLOWLOCATION', true );
    
    curl.on( 'end', function( statusCode, body, headers ) {
    
        console.info( statusCode );
        console.info( '---' );
        console.info( body.length );
        console.info( '---' );
        console.info( this.getInfo( 'TOTAL_TIME' ) );
    
        this.close();
    });
    
    curl.on( 'error', function ( err, errCode ) {
    
        //do something
    
        this.close();
    });
    
    curl.perform();
    

    Disclaimer: I’m the author, it’s a modified version of another module: https://github.com/jiangmiao/node-curl.