title: Select option from dropdown and submit request using nodejs
body: <p>I am working on nodejs for scrapping a website and I am very new to nodejs.The website initial page is a popup in which one has to select option from selectbox and submit only then later pages can be browsed.this has to be done for first time and then it will be stored as cookie for later use.</p>
  
  <p>I am able to get html page of popup but I am not able to select option from selectbox and submit request.</p>
  
  <p>Here is my Code </p>
  
  <pre><code>var express = require('express');
  
  var request=require('request');
  var cheerio=require('cheerio');
  var j = request.jar();
  //var cookie = request.cookie();
  j.setCookie("city_id=1; path=/; domain=.bigbasket.com", 'http://bigbasket.com/', function(error, cookie) {
      //console.log("error"+error.message);
      console.log("cookie "+cookie);
  });
  
  var app=express();
  
  
  app.get('/', function(req, res){
      console.log("hi");
      var sessionVal = req.session;
      request({uri:'http://bigbasket.com/',
      headers:{'User-Agent': 'Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.81 Safari/537.36' ,
               'content-type':'application/x-www-form-urlencoded; charset=UTF-8',
               'connection':'keep-alive'},
                jar:j},
          function(err, response, body) {
           //   console.log("err "+err.message);
          console.log("header"+JSON.stringify(response.headers));
          console.log("status"+response.statusCode);
              console.log("cookie "+response.cookie);
  
              console.log(body);
              var $=cheerio.load(body,{xmlMode: true});
              console.log($);
              var $selectBox= $('select').filter('.selectboxdiv');
  
              console.log($selectBox.text());
  
              response.end;
  
      });
  
  
  });
  app.listen('8081')
  console.log('Magic happens on port 8081');
  exports = module.exports = app;
  </code></pre>
  
  <p>I am able to get select box options through below code :</p>
  
  <pre><code>var $selectBox= $('select').filter('.selectboxdiv');
  
                  console.log($selectBox.text());
  </code></pre>
  
  <p>But I am not able to select that option and submit.I have to select city from dropdown menu and submit request so that I could scrape data from upcoming webpages.</p>