IPageRequest | PhantomJsCloud.com API Documentation
The parameters for requesting and rendering a page. When you submit an array of IPageRequests, they are loaded in-order, and only the last one is rendered. All variables except 'url' are optional.
Hierarchy
- IPageRequest
Index
Properties
Properties
Optional backend
choose what browser renders your request
- default
"default"
Optional content
content: string
if specified, will be used as the content of the page you are loading (no network request will be made for the url).
If you do not provide a url] then http://localhost/blank will be used as the target Url for your content.
Alternatively, you can provide a url as the content. This will load the contents of the url and use that as the content string.
- example
{url:"http://example.com/page1",content:"http://example.com/page2", renderType:"png"} //replace the contents of page1 with those of page2 and takes a screenshot {url:"<h1>Hello, World!</h1>", renderType:"png"} //loads http://localhost/blank with the contents "<h1>Hello, World!</h1>" and takes a screenshot
Optional outputAsJson
output
TRUE to return the page contents and metadata as a JSON object. see IUserResponse if FALSE, we return the rendered content in it's native form.
Optional overseerScript
overseer
NEW AUTOMATION API
This api allows unparalleled control over your browser request. Using this Automation API you will be able to do the following things easily:
- USER INPUT: Control the Keyboard, Mouse, or Touchscreen directly, as a human would.
- MULTI-RENDERS: Render multiple screenshots or PDF's of the page, at times you decide.
- CUSTOM LOGIC: A secure sandbox allows custom code (
ES2018javascript) execution inside your API call. This enables dynamic query/manipulation of the page. Full control over the browser. - PUPPETEER SCRIPTS: Puppeteer script compatibility. Currently 80% of Puppeteer API's are supported
See the Automation API Docs for more details.
Usage:
- If you pass in an overseerScript, the url fields is optional (as you can navigate to one or many url's from your overseerScript).
- Consider also using the
renderType:"automation"to display only your automation output.
Optional proxy
proxy: string
shortcut for using our builtin proxy service. Please use IUserRequest.proxy for full configuration options ( IProxyOptions )
Geolocation using Static IP Costs an additional $0.25/gb ingress.
- "
geo-us" all your requests use a single, static IP (35.188.112.61) from the USA.
- "
Anonymous Proxy Costs an additional $0.50/gb ingress
- "
anon-{country-code}" Each request uses a different, anonymous IP address. Chooseanyfor the largest selection of IP addresses from anywhere in the world. Other choices includecn(China),nl(Netherlands),us(USA). Please see http://phantomjscloud.com/examples/helpers/proxy-builtin-locations for a complete list.
- "
Custom Proxy No additional cost.
- "
custom-{proxyUrl}:{port}:{username}:{password}" Use a 3rd party proxy of your own choice. username and password are optional.
- "
- example
//POST request JSON payload to use a worldwide anonymous proxy { url:"https://phantomjscloud.com/examples/helpers/requestdata", proxy:"anon-any"} //anonymous proxy from Netherlands { url:"https://phantomjscloud.com/examples/helpers/requestdata", proxy:"anon-nl"} //static IP from USA { url:"https://phantomjscloud.com/examples/helpers/requestdata", proxy:"geo-us"} //use your custom 3rd party proxy { url:"https://phantomjscloud.com/examples/helpers/requestdata", proxy:"custom-http://myProxy.com:8838:myname:secret"}
Optional queryJson
query
use JSONata to query the userResponse object. Used in conjunction with suppressJson this allows you to reduce outputAsJson verbosity and only return the data you want.
You may pass multiple queries (comma delimited string array of queries). Each query's result will be appended to the IUserResponse.queryJson node.
See http://jsonata.org/ for how to create your own custom query
- example
//request JSON showing how to return only "requestFinished" events and the content data { url:"http://www.example.com", suppressJson:["pageResponses","originalRequest","content","meta.trace"], queryJson:["pageResponses.events[key='requestFinished']","content.data"], }
Optional renderSettings
settings related to rendering of the last page of your request. See the IRenderSettings documentation (below) for details
Optional renderType
render
html: returns the html text,
jpeg | jpg : The default. renders page as jpeg. transparency not supported. (use png for transparency). Max height/width is 20000px. If you need bigger, let support@phantomjscloud.com know. ,
png: renders page as png. Max default height/width is 10000px. If you need bigger, set IRenderSettings.clipRectangle or IRenderSettings.selector directly (such as renderSettings.selector:"body"). ,
pdf: renders page as a pdf,
script: DEPRECATED: use the new Automation API instead. returns the contents of window['_pjscMeta'].scriptOutput. see the IScripts parameter for more details,
plainText: return the text without html tags (page plain text),
automation: NEW output only the results from the automation IPageRequest.overseerScript. See IAutomationResult for a description of this JSON output. If you set <a href="ipagerequest.html#outputasjson">outputAsJson</a>:true,
automation Results will always be found under IPageResponse.automation but if renderType:"automation" is set, userResponse.content.data will also be set to the IAutomationResult json.
Optional requestSettings
settings related to requesting internet resources (your page and resources referenced by your page)
Optional scriptSettings
new for Chrome backend. (not available on WebKit).. extra settings if you use injected scripts.
Optional scripts
Execute your own custom JavaScript inside the page being loaded.
see IScripts docs for more details.
Optional suppressJson
suppress
add the nodes from your pageResponse that you do not wish to transmit. Used in conjunction with queryJson this allows you to reduce outputAsJson verbosity and only return the data you want, thus reducing cost and transmission time. if you need the data in these nodes, simply remove it from this array. pass an empty array to return all nodes.
important: do not suppress the "meta" node. However you can suppress "meta.trace" if you wish.
- example:
//POST request JSON payload { url:"https://phantomjscloud.com/examples/helpers/requestdata", suppressJson: [ "pageResponses.events.value.request.headers", "pageResponses.events.value.response.headers", "pageResponses.frameData.content", "pageResponses.frameData.childFrames" ] }
url
url: string
The target page you wish to load. Either url or content is required.
Optional urlSettings
adjustable parameters for when making network requests to the url specified.
- example
//make a POST request { url:"http://example.com",urlSettings:{ operation:"POST", data:"{ yourData: 1 }", contentType:"application/json" },}