let articleHTML = contentDOM.html();
$('.job_bt') .find('div') .html()
els.each((i, el) => { const section = doc(el); const html = section.html().trim(); if (countWord(html) >= MIN_SECTION_LENGTH) { parts.push(html); } });
/** * 获取首页段子 */ router.get('/duanzi', function (req, res) { superagent.get('https://github.com/loverajoel/jstips/').end(function (err, xhr) { var $ = cheerio.load(xhr.text); var html = $('#user-content-tips-list').closest('h1').next('ul').find('li').html(); res.send(html); }); });
/* * Note: I place empty line comments after JSX because my editor can't distinguish between closing JSX tags and starting regexes. ¯\_(ツ)_/¯ */ describe('<Copyright/>', () => { test('Copyright content properly output', () => { const copyright = render(<Copyright/>); // expect(copyright.hasClass(styles.copyright)).toBe(true); expect(copyright.html()).toContain('Copyright'); expect(copyright.html()).toContain('Michael Landis'); }); });
function parseHTML (html, selector) { const $ = cheerio.load(html) return $(selector) .map(function () { return ($(this).html() || '').replace(/\s+/g, ' ') } ).get().join(', ') }
function getftpLink(link){ return new Promise(function(resolve,reject){ request.get(link,function(err,res,body){ if(!err && res.statusCode == 200){ var $ = cheerio.load(body); var ftp = $('#showinfo').find('table tbody tr td a').html(); resolve(ftp); }else{ reject('failed to get the ftp!'); } }); }); }
// Concatenate matching paragraphs $(p).each((index, el) => { excerpt += '<p>' + $(el).html() + '</p>'; });
function asciidoctorRenderer(data, locals) { var html = asciidoctor.convert(data.text, asciidoc_options); var $ = cheerio.load(html, cheerio_load_option); $('.highlight code').each(function(index, elem) { options.lang = elem.attribs['data-lang']; var code = entities.decodeXML($(elem).text()); var content = util.highlight(code, options); $(elem).html(content); }); return $.html() .replace(/{/g, '{') .replace(/}/g, '}'); }
request(`http://www.instagram.com/` + username, function (err, resp, html) { if (!err) { if (resp.statusCode == 200) { const $ = cheerio.load(html); $('body').children().each((i, e) => { eleHTML = $(e).html() if (eleHTML.indexOf('window._sharedData') > -1) { resolve(JSON.parse(eleHTML.split('"ProfilePage":[')[1].split(']},"hostname"')[0]).graphql.user.profile_pic_url_hd) return false; } }) } else reject(resp.statusCode); } else reject(err); });
function getListByEventKey(eventKey){ return new Promise(function(resolve,reject){ getPageByUrl().then(function(movieList){ for(var i=0;i<movieList.length;i++){ request.get(movieList[i].link,function(err,res,body){ if(!err && res.statusCode == 200){ var $ = cheerio.load(body); var ftp = $('#showinfo').find('table tbody tr td a').html(); movieList[i].ftp = unescape(ftp.replace(/;/g,'').replace(/&#x/g, "%u")); }else{ reject('failed to get the ftp!'); } }); resolve(movieList); } }); }); }
_buildErrorPage(errorFrameHtml) { let $ = cheerio.load(errorFrameHtml, { decodeEntities: false }) let p404 = { title: "页面未找到 - " + this.config.doc.name, path: this.buildDir + "/teadocs_error_pages/404.html", description: "404错误!该页面未找到,试试从左边菜单栏访问别的页面,或者从左上角搜索你想要的内容。" } $(".top-title span").text('404页面未找到') $("meta[name='keywords']").attr("content", p404.title) $("meta[name='description']").attr("content", p404.description) $("title").text(p404.title) $("article.markdown-body").html(p404.description) console.log(chalk.green(">>>"), "output:", p404.path) let liEls = $("ul > li > a.active") liEls.each((i, elem) => { $(elem).removeClass("active") }) utils.writeFile(p404.path, $.html()) }
$('table.WRD') .map(function (i, el) { return $(this).html() }) .get()
request(url,(error, response, html) => { if(!error && response.statusCode == 200){ //console.log(html); const $ =cheerio.load(html); const loginTest = $('.main-content'); console.log(loginTest.html()); // console.log('finsh'); // $('.account-wall-login').each(function(i, element){ // const $element = $(element); // console.log($element); // console.log('==========='); // console.log($element.text()); // console.log('==========='); // }) }else{ console.log('an error occured'); } })
request(`http://www.instagram.com/` + username, function (err, resp, html) { if (!err) { if (resp.statusCode == 200) { const $ = cheerio.load(html); $('body').children().each((i, e) => { eleHTML = $(e).html() if (eleHTML.indexOf('window._sharedData') > -1) { resolve(JSON.parse(eleHTML.split('"ProfilePage":[')[1].split(']},"hostname"')[0]).graphql.user); return false; } }) } else reject(resp.statusCode) } else reject(err); })