Enter your contact information.
Enter your project information.
Step 3Choose the PHP programmers you want to hire.
Compare Free PHP Quotes
NodeJS cURL Tutorial
*Attention PHP Programmers* - Add A Free Listing! Get more clients.
NodeJS is a powerful evented JavaScript platform running on top of Google’s V8 javascript engine. Over the last year the popularity of NodeJS has increased greatly, as shown by the number of discussions on programming forums such as Hacker News, Reddit and Stackoverflow. Despite this NodeJS is still young and it falls short to Python and Ruby when it comes to the number and range of libraries and modules available.
The Problem
I wanted to convert one of my web scraping applications I made in PHP to NodeJS. The application interacts with SOCKS4 and SOCKS5 proxies using PHP’s cURL bindings. Unfortunately there are no cURL bindings (or SOCKS protocol wrappers) written for NodeJS. NodeJS does come with an HTTP client module that can issue web requests, however it doesn’t support SOCKS proxies.
The Solution
Although there are no specific NodeJS bindings for cURL, we can still issue cURL requests via the command line interface. NodeJS comes with the child_process module which easily allows us to start processes and read their output. Doing so is fairly straight forward. We just need to import the exec method from the child_process module and call it. The first parameter is the command we want to execute and the second is a callback function that accepts error, stdout, stderr.
The Code
var util = require('util');
var exec = require('child_process').exec;
var command = 'curl -sL -w "%{http_code} %{time_total}\n" "http://query7.com" -o /dev/null'
child = exec(command, function(error, stdout, stderr){
console.log('stdout: ' + stdout);
console.log('stderr: ' + stderr);
if(error !== null)
{
console.log('exec error: ' + error);
}
});
This returns the HTTP code and time it took for the request to be issued:
stdout: 200 0.710
Conclusion
Although NodeJS is still young and bindings haven’t been made for alot of C libraries, the code above shows how you can still interact with the functionality they provide. That being said, the number of NodeJS modules is growing weekly. Be sure to keep an eye on the module wiki and npm registry for a list of modules.
Source http://query7.com/?p=1369Mon, 28 Mar 2011 01:34:25 GMT
Tags: JavaScript, nodejs, Programming, Tutorials, Web Development,
*Attention PHP Programmers* - Add A Free Listing! Get more clients.
JavaScript
JavaScript Fade Tutorial – Fading Elements In/Out
One of the most common JavaScript effects is fading elements and text in and out. Fortunately, it isn't very difficult to script and doesn't require a JavaScript framework.
JavaScript Slider – TinySlider 2
This full-featured and standalone JavaScript slider is easily configurable and visually customizable using CSS. It also clocks in at a tiny 3KB.
Simple AJAX Function with Example
TinyAjax is a simple AJAX function that makes it easy to call and process GET and POST transactions. Check out the example.
nodejs
Programming
Cussing in Commits: Which Programming Language Inspires the Most Swearing?
As any programmer can tell you, programming will make you swear. But did you know that writing C++ will make you swear considerably more than PHP or Python? Developer Andrew Vos was looking for a weekend project when he decided to grab some one million co
Amazon S3 Storage Now Handles Entire Websites
Cheap, cloud-hosted web servers are a key component of a distributed web. But sometimes you don’t need a server, you just need a cheap way to host your static files, like images and videos. That’s the gap Amazon’s S3 service has long fil
Who Swears the Most? How Foursquare Used Hadoop to Find Out
We told you who swears the most in their code, but what about in the real world? Foursquare, the location check-in service, has used its rather large dataset to graph the “rudest” places in the English-speaking world — Manchester, U.K. t
Web Design, Graphic Design, SEO, Web Hosting, Servers and Marketing Solutions. Prices start at only $50!
Stockbridge, Georgia US
Perlman Creative Group is a Los Angeles based, full service graphic design firm specializing in marketing communication, brand development, logos, packaging, corporate identity and website design.
Marina Del Rey, California US
German freelance PHP programmer with 5 years of experience in PHP, MySQL, HTML, CSS, AJAX, Photoshop, PHP frameworks (CodeIgniter, Typo3, Joomla, etc.), Linux Server administration, JAVA, C# and C++.
Melbourne, Victoria AU
Mozilla Building Metro Version of Firefox for Windows 8
Mozilla is planning to build a dramatically different version of Firefox for Windows 8, one that wil
Adobe Acquires Typekit Web-Font Service
Adobe has purchased Typekit, one of the driving forces behind the growth of creative web typography.
Titanium Mobile Android Development: Soundboard App
In this series of tutorials we use Appcelerator’s Titanium Mobile platform to create Android appl
Back Up Your Gmail Account With Gmvault
The more you rely on cloud-based services, the more important good backups become. If you're using G
Review: Lightroom 4 Beta Offers Subtle, but Worthwhile Improvements
Adobe has released a free public beta preview of its coming Lightroom 4 image editor. On the surface
Article Tags
PHP Programmers Articles
Live Help Chat Software
Web Design Quote
Web Design