本文整理汇总了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 };
}