本文整理匯總了TypeScript中jsdom.JSDOM.fromURL方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript JSDOM.fromURL方法的具體用法?TypeScript JSDOM.fromURL怎麽用?TypeScript JSDOM.fromURL使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類jsdom.JSDOM
的用法示例。
在下文中一共展示了JSDOM.fromURL方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: test_fromURL
function test_fromURL() {
const options = {} as FromUrlOptions;
JSDOM.fromURL('https://example.com/', options).then(dom => {
console.log(dom.serialize());
});
}
示例2: analyzeComicPage
private async analyzeComicPage(url: string): Promise<Comic> {
const ogp = await grabity.grabIt(url),
document = (await JSDOM.fromURL(url)).window.document,
topicMsg = document.getElementById("topics2").textContent;
const comic = {
url,
title: fixchar(ogp.title || ogp["og:title"] || ogp["twitter:title"]).trim(),
thumbnailURL: ogp.image || ogp["og:image"] || ogp["twitter:image:src"],
concluded: (topicMsg.includes("連載は終了しました") || topicMsg.includes("特別読切作品")),
episodes: this.scrapeEpisodes(document),
};
console.info(`MagGarden: Crawled Comic Page - ${comic.title}`);
return comic;
}
示例3: analyzeMagazinePage
protected async analyzeMagazinePage(
url: string,
name: string,
id: string,
): Promise<Magazine> {
const document = (await JSDOM.fromURL(url)).window.document,
comics: Comic[] = [];
for (const comicBox of Array.from(document.querySelectorAll("article.cbox"))) {
const comicURL = comicBox.querySelector(".inner > a.cbox-main").getAttribute("href");
comics.push(await this.analyzeComicPage(comicURL));
}
this.comics = comics;
console.info("MagGarden: Crawled Magazine Index");
return { id, name, comics };
}