本文整理汇总了TypeScript中webpage.create函数的典型用法代码示例。如果您正苦于以下问题:TypeScript create函数的具体用法?TypeScript create怎么用?TypeScript create使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了create函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: require
const webpageMod = require('webpage'); // tslint:disable-line no-var-requires
const webserverMod = require('webserver').create(); // tslint:disable-line no-var-requires
let page = webpageMod.create();
let vUrl = 'https://www.w3c.org';
function testWebserver() {
webserverMod.close();
webserverMod.listen(1234);
webserverMod.registerFile("urlPath", "filePath");
webserverMod.registerDirectory("urlPath", "dirPath");
}
let vUserAgent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/602.4.8 (KHTML, like Gecko) Version/10.0.3 Safari/602.4.8';
page.settings.userAgent = vUserAgent;
page.onConsoleMessage = (vMsg) => {
};
page.onAlert = (vMsg) => {
};
page.onLoadStarted = () => {
};
page.captureContent = [/json/];
page.onResourceReceived = (oResponse) => {
oResponse.id;
oResponse.bodySize;
oResponse.body;
开发者ID:AbraaoAlves,项目名称:DefinitelyTyped,代码行数:31,代码来源:slimerjs-tests.ts
示例2: require
const system: System = require('system');
const url = system.args[1];
if (!url) {
console.log('Usage: phantomjs extractor.js "<some URL>" "<JSON config>"');
phantom.exit(1);
}
import { create as createWebPage } from 'webpage';
const page = createWebPage();
/**
* This callback is invoked when there is a JavaScript console message on the web page
* @param {string} message
* @param {number} lineNum
* @param {string} sourceId
*/
page.onConsoleMessage = function (message, lineNum, sourceId) {
console.log('CONSOLE: ' + message + ' (from line #' + lineNum + ' in "' + sourceId + '")');
};
/**
* This callback is invoked when the page requests a resource
* @param {requestData} request
* @param {networkRequest} network
*/
page.onResourceRequested = function (request, network) {
// other unnecessary links
if (request.url.indexOf('facebook.com') !== -1
|| request.url.indexOf('twitter.com') !== -1
开发者ID:chen-framework,项目名称:crawler,代码行数:31,代码来源:extractor.ts
示例3: require
declare var phantom: any;
var webpage = require('webpage');
var system = require('system');
var page = webpage.create();
var address: string;
var output: string;
address = system.args[1];
output = system.args[2];
page.viewportSize = { width: 1024, height: 768 };
page.paperSize = { format: 'A4', orientation: 'portrait', margin: '1cm', border: '0px' };
page.open(address, function (status: string): void {
if (status !== 'success') {
console.log('Unable to load the address!');
console.log(status);
console.log(address);
console.log(output);
phantom.exit();
} else {
page.render(output);
phantom.exit();
}
});
开发者ID:villers,项目名称:OnlineMarkdownEditorApi,代码行数:25,代码来源:render.ts
注:本文中的webpage.create函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论