Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

191
Views
Webscraping using Nodejs - <ul> tags

I am trying to scrape a stock market web page for the titles of href links. I don't get any output. I tried calling the class, id's,etc. I see the tag has a $0 assigned. I typed this in the console command line but it just showed the same thing.

I am trying to get the text "Bulk Deals" from the html. If I can figure how that's done, I can proceed.

Code:

  var cheerio = require('cheerio');
    var request = require('request');

    var url ="http://feeds.feedburner.com/nseindia/CMDailyReport";
    request(url, function(err, resp, body){
    	var $ = cheerio.load(body);
    	$(".regularitem .itemtitle").each(function(){
    		var link = $(this);
    		var text = link.text();
        		var href = link.attr("href");

    	 	console.log(text + href);
    	
    	});    

    });
    <ul>
    	<li xmlns:dc="http://purl.org/dc/elements/1.1/" class="regularitem">
    		<h4 class="itemtitle">
    			<a href="http://feedproxy.google.com/~r/nseindia/CMDailyReport/~3/P9Aw3__Tm9M/bulk.csv">Bulk Deals</a></h4>
    		<h5 class="itemposttime"></h5>
    		<div class="itemcontent" name="decodeable"><div class="feedflare">
    	<a href="http://feeds.feedburner.com/~ff/nseindia/CMDailyReport?a=P9Aw3__Tm9M:Clpwmq7B-_I:yIl2AUoC8zA">
    		<img src="http://feeds.feedburner.com/~ff/nseindia/CMDailyReport?d=yIl2AUoC8zA" border="0">
    	</a> 
    	<a href="http://feeds.feedburner.com/~ff/nseindia/CMDailyReport?a=P9Aw3__Tm9M:Clpwmq7B-_I:F7zBnMyn0Lo">
    		<img src="http://feeds.feedburner.com/~ff/nseindia/CMDailyReport?i=P9Aw3__Tm9M:Clpwmq7B-_I:F7zBnMyn0Lo" border="0">
    	</a> 
    	<a href="http://feeds.feedburner.com/~ff/nseindia/CMDailyReport?a=P9Aw3__Tm9M:Clpwmq7B-_I:qj6IDK7rITs">
    		<img src="http://feeds.feedburner.com/~ff/nseindia/CMDailyReport?d=qj6IDK7rITs" border="0">
    	</a> 
    	<a href="http://feeds.feedburner.com/~ff/nseindia/CMDailyReport?a=P9Aw3__Tm9M:Clpwmq7B-_I:gIN9vFwOqvQ">
    		<img src="http://feeds.feedburner.com/~ff/nseindia/CMDailyReport?i=P9Aw3__Tm9M:Clpwmq7B-_I:gIN9vFwOqvQ" border="0">
    	</a>
    	</div>
    		<img src="http://feeds.feedburner.com/~r/nseindia/CMDailyReport/~4/P9Aw3__Tm9M" height="1" width="1" alt="">
    	</div>
    </li>

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

When you do $(".regularitem .itemtitle"), you're getting the <h4> and not the link (<a>) that is inside it.

To get the "Bulk Deals", you can do the following in your browser (or click on the 'Run code snippet' button):

var html = `<li xmlns:dc="http://purl.org/dc/elements/1.1/" class="regularitem">
		<h4 class="itemtitle">
			<a href="http://feedproxy.google.com/~r/nseindia/CMDailyReport/~3/P9Aw3__Tm9M/bulk.csv">Bulk Deals</a></h4>
		<h5 class="itemposttime"></h5>
		<div class="itemcontent" name="decodeable"><div class="feedflare">
	<a href="http://feeds.feedburner.com/~ff/nseindia/CMDailyReport?a=P9Aw3__Tm9M:Clpwmq7B-_I:yIl2AUoC8zA">
		<img src="http://feeds.feedburner.com/~ff/nseindia/CMDailyReport?d=yIl2AUoC8zA" border="0">
	</a> 
	<a href="http://feeds.feedburner.com/~ff/nseindia/CMDailyReport?a=P9Aw3__Tm9M:Clpwmq7B-_I:F7zBnMyn0Lo">
		<img src="http://feeds.feedburner.com/~ff/nseindia/CMDailyReport?i=P9Aw3__Tm9M:Clpwmq7B-_I:F7zBnMyn0Lo" border="0">
	</a> 
	<a href="http://feeds.feedburner.com/~ff/nseindia/CMDailyReport?a=P9Aw3__Tm9M:Clpwmq7B-_I:qj6IDK7rITs">
		<img src="http://feeds.feedburner.com/~ff/nseindia/CMDailyReport?d=qj6IDK7rITs" border="0">
	</a> 
	<a href="http://feeds.feedburner.com/~ff/nseindia/CMDailyReport?a=P9Aw3__Tm9M:Clpwmq7B-_I:gIN9vFwOqvQ">
		<img src="http://feeds.feedburner.com/~ff/nseindia/CMDailyReport?i=P9Aw3__Tm9M:Clpwmq7B-_I:gIN9vFwOqvQ" border="0">
	</a>
	</div>
		<img src="http://feeds.feedburner.com/~r/nseindia/CMDailyReport/~4/P9Aw3__Tm9M" height="1" width="1" alt="">
	</div>
</li>`
var parser = new DOMParser();
var doc = parser.parseFromString(html, "text/html");

Array.from(doc.querySelectorAll(".regularitem .itemtitle")).forEach(function(h4) {
  var link = h4.getElementsByTagName('a')[0];
  console.log(link.innerHTML);
});

Hope it helps,

Best regards

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!