javascript - Select option from dropdown and submit request using nodejs -
i working on nodejs scrapping website , new nodejs.the website initial page popup in 1 has select option selectbox , submit later pages can browsed.this has done first time , stored cookie later use.
i able html page of popup not able select option selectbox , submit request.
here 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, 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;
i able select box options through below code :
var $selectbox= $('select').filter('.selectboxdiv'); console.log($selectbox.text());
but not able select option , submit.i have select city dropdown menu , submit request scrape data upcoming webpages.
edit:
what see if use 'req.body.name_of_your_dropdown_here'? maybe can see selected option then?
Comments
Post a Comment