
Example Golden Gate Webcam
Deprecated
Pricing
Pay per usage
Go to Store

Example Golden Gate Webcam
Deprecated
Example actor that opens a webpage with Golden Gate webcam. It takes a screenshot from the cam and saves it as output to the key-value store. You can easily use it as API that returns a screenshot with https://api.apify.com/v2/acts/apify~example-golden-gate-webcam/run-sync?token=[YOUR_API_TOKEN]
0.0 (0)
Pricing
Pay per usage
5
Total users
21
Monthly users
3
Last modified
3 years ago
Dockerfile
# This is a template for a Dockerfile used to run acts in Actor system.# The base image name below is set during the act build, based on user settings.# IMPORTANT: The base image must set a correct working directory, such as /usr/src/app or /home/userFROM apify/actor-node-chrome:v0.21.10
# Second, copy just package.json and package-lock.json since it should be# the only file that affects "npm install" in the next step, to speed up the buildCOPY package*.json ./
# Install NPM packages, skip optional and development dependencies to# keep the image small. Avoid logging too much and print the dependency# tree for debuggingRUN npm --quiet set progress=false \ && npm install --only=prod --no-optional \ && echo "Installed NPM packages:" \ && (npm list --all || true) \ && echo "Node.js version:" \ && node --version \ && echo "NPM version:" \ && npm --version
# Copy source code to container# Do this in the last step, to have fast build if only the source code changedCOPY . ./
# NOTE: The CMD is already defined by the base image.# Uncomment this for local node inspector debugging:# CMD [ "node", "--inspect=0.0.0.0:9229", "main.js" ]
package.json
{ "name": "apify-project", "version": "0.0.1", "description": "", "author": "It's not you it's me", "license": "ISC", "dependencies": { "apify": "0.21.10" }, "scripts": { "start": "node main.js" }}
main.js
1const Apify = require('apify');2
3Apify.main(async () => {4 // Launch web browser.5 const browser = await Apify.launchPuppeteer({ headless: true });6
7 // Load http://goldengatebridge75.org/news/webcam.html and get an IFRAME with the webcam stream8 console.log('Opening web page...');9 const page = await browser.newPage();10 await page.goto('http://goldengatebridge75.org/news/webcam.html');11 const frames = await page.frames();12 const iframeWithVideo = frames[1];13
14 // Wait for the webcam to load.15 console.log('Waiting for the webcam image.');16 const imageElementHandle = await iframeWithVideo.waitForSelector('.VideoColm img[src^="blob:"]');17 // Wait a little more to give the browser a chance to display the image.18 await page.waitFor(1000);19
20 // Get a screenshot of that image.21 const imageBuffer = await imageElementHandle.screenshot();22 console.log('Screenshot captured.');23
24 // Save the screenshot as the actor's output. By convention, similarly to "INPUT",25 // the actor's output is stored in the default key-value store under the "OUTPUT" key.26 await Apify.setValue('OUTPUT', imageBuffer, { contentType: 'image/jpeg' });27 console.log('Actor finished.');28});