コード例 #1
0
ファイル: example.ts プロジェクト: atd-schubert/node-webcheck
 $(".repo-list-item").each((i: number, elem: any) => {
     const proof = {};
     webcheck.crawl({
         proof,
         test: "license",
         title: $(elem).find("h3").text().trim(),
         url: url.resolve(result.url, $(elem).find("h3 a").attr("href")) + "/blob/master/LICENSE",
     });
     webcheck.crawl({
         proof,
         test: "readme",
         title: $(elem).find("h3").text().trim(),
         url: url.resolve(result.url, $(elem).find("h3 a").attr("href")) + "/blob/master/README.md",
     });
 });
コード例 #2
0
ファイル: example.ts プロジェクト: atd-schubert/node-webcheck
/**
 * An example how to use webcheck
 * @author Arne Schubert <*****@*****.**>
 */

import * as url from "url";
import { IResult, Webcheck } from "webcheck";
import { CheerioPlugin } from "webcheck-cheerio";

const webcheck = new Webcheck({ // Instantiate webcheck
    concurrency: 1,
    headers: {
        "User-Agent": "Webcheck example crawler",
    },
});

const cheerio = new CheerioPlugin();
webcheck.addPlugin(cheerio);

cheerio.enable();

/*
 * Our own plugin
 *
 * It is much better to require a middleware as a module.
 */

const username = "******";

webcheck.on("result", (result: IResult) => {
    const arr: string[] = [];