Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
page.sections.forEach((section) => {
if (section == undefined || section.content == undefined) {
return true;
}
$ = cheerio.load(section.content);
// Find asciidoc admonition block.
$(".admonitionblock").each(function () {
$this = $(this);
// Look at classes, should include the admonition type along with other irrelevant stuff.
candidateClasses = $(this)[0].attribs.class.split(/\s+/);
// Find the admonition class
admonClass = candidateClasses.find(klazz => options[klazz]);
// Skip if no relevant candidate found
if (admonClass === undefined) {
return true;
}
// Admonishment
admon = options[admonClass];
// Replacement we'll sub in.
iconElem = $("<div></div>")
.addClass(admon.classes)
var parse = function(html, word){
var $ = require('cheerio').load(html);
var ok = false;
$('#TableHTMLResult .ldcomIN').each(function(){
var value = $(this).text().trim();
var match = matcher(value);
// console.log('['+value+']', 'match=', match, 'ok=', ok);
if (ok && !match){ ok = value; return false; } // Break loop
if (match){ ok = value; // Will take next value
if (value.indexOf(word) == 0){ return false; }
}
});
return ok;
}
request(url, function(error, response, body){
// loads page into jquery
var $ = cheerio.load(body);
// selects human readable text
var text = $('body').text();
// Jquery alternative to remove tags
// text = body.replace(/(<([^>]+)>)/ig, '');
// removes large whitespaces
text = text.replace(/\s+/g, ' ');
// removes non alpha-numeric characters
text = text.replace(/[^\w\s]/gi, '');
// white to file
write(text);
console.log('Writing Data for: ' + url);
target = 'ul.vmonth';
break;
case 'year':
target = 'ul.vyear';
break;
default:
target = 'ul.wlist';
}
const list_url = base_url + '/wtfy.html';
const response = await got({
method: 'get',
url: list_url,
});
const data = response.data; // content is html format
const $ = cheerio.load(data);
// get urls
const detail_urls = [];
let a = $(target).find('a.rtitle');
if (!a || a.length <= 0) {
a = $(target).find('div.li-title > a');
}
for (let i = 0; i < a.length; ++i) {
const tmp = $(a[i]).attr('href');
detail_urls.push(tmp);
}
// get articles
const article_list = await Promise.all(detail_urls.map((url) => get_article(url)));
results.forEach(html => {
const $ = cheerio.load(html)
expect($('.comment-thread-renderer').length).to.be.above(1)
expect($('.comment-renderer').length).to.be.above(1)
})
done()
before(function(done) {
var page = pages['/other/index.md']
$input = cheerio.load(page.input)
page.render(context, function(err, output){
$output = cheerio.load(output)
done()
})
})
request(docs[index].url, (error, response, body) => {
logger.info('statusCode===>' + response.statusCode);
if (!error && response.statusCode == 200) {
let $ = cheerio.load(body);
let _info = $('#info').html().split('<br>');
let _name = $('#wrapper').find('h1').text().trim();
logger.info('BookName: ' + _name);
//logger.info($('#link-report').find('.intro').text());
var _desc = $('#link-report').find('.intro').find('p');
let de = [];
for (let i = 0; i < _desc.length; i++) {
de.push($(_desc[i]).text().trim())
}
let _item = {
name: _name,
pic: $('#mainpic').find('.nbg').attr('href'),
star: parseFloat($('#interest_sectl').find('.rating_num').text().trim()),
desc: de,
author: '',
press: '',
export const _getDocumentHandler = (html: string, option?: object): CheerioStatic => {
return cheerio.load(html, {
decodeEntities: false,
recognizeSelfClosing: true,
...option,
});
}
icons.forEach(i => {
const svg = fs.readFileSync(i, 'utf-8');
const id = path.basename(i, '.svg');
const ComponentName = (id === 'github') ? 'GitHub' : Case.pascal(id);
const $ = cheerio.load(svg, {
xmlMode: true,
});
const title = Case.capital(id);
const fileName = path.basename(i).replace('.svg', '.js');
const location = path.join(rootDir, 'lib/icons', fileName);
$('*').each((index, el) => {
if (el.name === 'svg') {
$(el).prepend('