Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource


Babel is required to process package imports. If you need a different preprocessor remove all packages first.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.


                <div class="pure-g wrapper">
  <div class="pure-u-5-5">
<h1>Get Comment Stats</h1>
<p>Enter the post URL into the field, wait, then get your data.</p>
<form class="pure-form">
<input placeholder="" id="url" name="url" />
<input type="submit" class="pure-button pure-button-primary" />

<span id="result"></span>
<p>Script by <a href="" target="_blank">me</a>.</p>


                .wrapper {
  padding: 1em;


                $('form').on('submit', function (e) {
  return false;

function scrapeSite(url) {
  var data = [];
  console.log("scrapping site...");
  $.get("" + url, function (response) {
    console.log("got result...");
    var talkback = $(response).find(".talkback");
    var comments = talkback.find("ul.timeline.all li");
    console.log("found " + comments.length + " comments.");
    // extract data from each comment
    comments.each(function (i) {
      var comment = $(this).find(">.text");
      // save data
      data[i] = {
        hearts: comment.find(">.tools>a.comment_love").text(),
        flashes: comment.find(">.tools>a.comment_hate").text(),
        datetime: comment.find(">.commentdate").text(),
        username: comment.find(">.userinfo>.name").text(),
        video: comment.find(">.content>.video").length,
        gif: comment.find(">.content>.image>.animated").length,
        image: comment.find(">.content>.image").length
    csvData = dataToCSV(data);
    resultText = "<a href='" + makeTextFile(csvData) + "' download='watson-comments.csv'>Download CSV as File</a><br /><h1>Data</h1><br />" + csvData;
    // end data extraction
    }).fail(function() {
      $("#result").text("failed to load page");

function dataToCSV(data) {
  var text = "username;date;hearts;flashes;video;gif;image<br />";
  for (i = 0; i < data.length; i++) {
    var comment = data[i];
    text += comment.username + ";" + comment.datetime + ";";
    text += comment.hearts + ";" + comment.flashes + ";";
    text += + ";" + comment.gif + ";" + comment.image + "<br />";
  return text;

String.prototype.replaceAll = function(search, replacement) {
  var target = this;
  return target.split(search).join(replacement);

function makeTextFile (text) {
    var textFile = "";
    // adjust for line breaks
    text = text.replaceAll("<br />", "\r\n");
    var data = new Blob([text], {type: 'text/plain'});

    // If we are replacing a previously generated file we need to
    // manually revoke the object URL to avoid memory leaks.
    if (textFile !== null) {

    textFile = window.URL.createObjectURL(data);

    // returns a URL you can use as a href
    return textFile;