I wanna embed bing search into Nodejs, I read the document a link. However, the method is about php, I cannot find a tutorial about how to use bing search in nodejs.(I am a newbie, I am not familiar with php. I tried to convert php code into nodejs and I failed since there is much difference between these two)
suppose, I have the bing.ejs like this:
<html>
<head>
<title>Bing Search Tester (Basic)</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<h1>Bing Search Tester (Basic)</h1>
<form method="POST" action="/bing">
<label for="service_op">Service Operation</label><br/>
<input name="service_op" type="radio" value="Web" CHECKED /> Web
<input name="service_op" type="radio" value="Image" /> Image
<br/>
<label for="query">Query</label><br/>
<input name="query" type="text" size="60" maxlength="60" value="" /><br /><br />
<input name="bt_search" type="submit" value="Search" />
</form>
<h2>Results</h1>
{RESULTS}
</body>
</html>
How can I write code in
app.post('/bing', function(req, res) {
var service_op = req.body.service_op;
var query = req.body.query;
//something to add...
});
What should I write next? or can anyone give me a template? thx!
This works for me:
This code uses the
request
module, so install that first: