From the course: D3.js Essential Training for Data Scientists

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Parsing HTML

Parsing HTML - D3.js Tutorial

From the course: D3.js Essential Training for Data Scientists

Start my 1-month free trial

Parsing HTML

- [Instructor] D3 allows you to download webpages or parts of webpages. Perhaps a particular html element on a webpage always contains public economic data and you want to drive a graphic on your site from this data. You wouldn't want to download the data or put it in a database to show it. Not if that meant you had to update your database every day. It's far cleaner to scrape the data off a webpage if you have permission. Just going to comment out these logs to the console and then we're going to write a D3.html handler. Using the D3.hmtl function is much like using the other functions to begin with. We pop the url in here and this time it's real url and I'm going to pop in this website here. Then we have .get as normal and inside .get we put the normal function and if we log that to the console, let's see what we have. We've still got a persistent xml line here so I'm just going to whip that out. There it is. Sneakily save that and refresh. So this is what we've been returned. It's…

Contents