Premt Premt - 1 year ago 109
HTML Question

NodeJS function not working

Hey am trying to add the parsed data to the table, but for some reason it's not getting added am still learning so I don't really know why I tried searching couldn't find anything


const {app, BrowserWindow} = require('electron');

let win;

app.on('ready', () => {
win = new BrowserWindow({width: 1280, height: 1080});

win.on('closed', () => {
win = null

// Quit when all windows are closed.
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {


<!DOCTYPE html>
<html lang="en">
<LINK rel="stylesheet" href="design.css" type="text/css">
<title>Today's Shows</title>
<meta charset="UTF-8">
<script>window.$ = window.jQuery = require('./jquery.min.js');</script>

<div id="page" class="yt-card">
<div class="tbl-header">
<div class="tbl-content">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%" id="myTable">
var cheerio = require('cheerio'),
$ = cheerio.load(`
<tr name="hover" class="forum_header_border">
<td class="forum_thread_post" width="35" align="center"><a href="/shows/1458/hunted/" title="Hunted Torrent"><img src="/images/eztv_show_info3.png" alt="Info" title="Hunted Torrents" border="0"></a></td>
<td class="forum_thread_post">
<a href="/ep/161087/hunted-2015-s02e06-720p-hdtv-x264-c4tv/" title="Hunted 2015 S02E06 720p HDTV x264-C4TV [eztv] (960.91 MB)" class="epinfo">Hunted 2015 S02E06 720p HDTV x264-C4TV [eztv]</a>
<td class="forum_thread_post" align="center">
<a href="magnet:?xt=urn:btih:a489093124274c23d6f52d16c5dd73d5da018489&amp;dn=Hunted.2015.S02E06.720p.HDTV.x264-C4TV%5Beztv%5D.mkv%5Beztv%5D&amp;;;;;" class="magnet" title="Hunted 2015 S02E06 720p HDTV x264-C4TV [eztv] (960.91 MB) Magnet Link" rel="nofollow"></a>
<a href="[eztv].mkv.torrent" rel="nofollow" class="download_1" title="Hunted 2015 S02E06 720p HDTV x264-C4TV Torrent: Download Mirror #1"></a>
<td class="forum_thread_post" align="center">960.91 MB</td>
<td class="forum_thread_post" align="center">26m 58s</td>
<td class="forum_thread_post" align="center"><span style="color: green; ">3</span></td>
<td class="forum_thread_post_end" align="center"><a href="/forum/discuss/161087/" rel="nofollow" title="Discuss about Hunted 2015 S02E06 720p HDTV x264-C4TV [eztv]:"><img src="/ezimg/s/1/3/chat_empty.png" alt="Discuss" title="Discuss about this show" width="16" border="0" height="16"></a></td>
<tr name="hover" class="forum_header_border">
<td class="forum_thread_post" width="35" align="center"><a href="/shows/1865/cant-pay-well-take-it-away/" title="Can't Pay? We'll Take It Away! Torrent"><img src="/images/eztv_show_info3.png" alt="Info" title="Can't Pay? We'll Take It Away! Torrents" border="0"></a></td>
<td class="forum_thread_post">
<a href="/ep/161084/cant-pay-well-take-it-away-s04e19-720p-hdtv-x264-c4tv/" title="Cant Pay Well Take It Away S04E19 720p HDTV x264-C4TV [eztv] (831.79 MB)" class="epinfo">Cant Pay Well Take It Away S04E19 720p HDTV x264-C4TV [eztv]</a>

$('td.forum_thread_post').each(function () {

var tElement = $(this).next();
var dElement =;
var sElement =;
tElement = getTitle(tElement);

var title = tElement.text();
var website = tElement.attr('href');
var download = getDownload(dElement);
var size = sElement.text();

if (!isEmpty(title) && !isEmpty(download) && !isEmpty(size) && !isEmpty(website)) {
console.log(`Title: ${title}\n Download: ${download}\n Size:${size}\n Website: ${website}`);

function getDownload(dElement) {
if (!isEmpty(dElement)) {

for (var i = 1; i < 3; i++) {
var download = dElement.children(`a.download_${i}`).attr('href');
if (!isEmpty(download)) {
return download;
return null;

function getTitle(tElement) {
if (!isEmpty(tElement)) {
var title = tElement.children('a');
if (!isEmpty(title)) {
return title;
return null;

function isEmpty(value) {
return typeof value == 'string' && !value.trim() || typeof value == 'undefined' || value === null;

function AddRow(website,size,title,download) {
var newRowContent = `<tr class="torItem"><td width="65.1%"><a class="download" target="_blank" href="${website}">${title}</a></td> <td width="8.5%">${size}</td> <td width="12%">FROM</td> <td width="12.9%"><a class="downbutton" href="${download}">Download</a></td></tr>`;


Thank you.

Answer Source

Package cheerio is not for client side implementation. You could use jQuery for that.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download