Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
geoscreenshot-api-example
Advanced tools
Example for consuming basic operations of the GeoScreenshot web capture API. The example makes calls to the capture web service to retrieve capture data and stores the image as a PNG file. The simple use case captures Yahoo Weather for all available plus
Readme
This is an example for the early release GS API Alpha. It captures Yahoo Weather Pages from several locations.
This simple script calls the GS API and generates PNG files.
For a given URL, it will simultaneously request screenshots for 1 or more locations and outputs PNGs and JSON Metadata in the specified directory.
The documentation for the web service can be found here: https://www.geoscreenshot.com/docs/
"use strict";
const config = {
'url': 'http://news.google.com',
'imageDir': './out/',
'verbose': true
};
const gs = require('./geoscreenshot')(config);
gs.locations()
.then(gs.filter('IN')) // Filter by country code
.then(gs.multicapture)
.then((results) => {
console.log("Captured ", results.length, "locations");
}, (error) => {
// Handle error
});
In your .js
file:
// Set default URL, defaults to Yahoo Weather and current dir respectively
const config = {
'url': 'http://www.example.com',
'imageDir': './out/'
};
const gs = require('./geoscreenshot')(config);
gs.gsCapture('http://www.example.com').then((result) => {
console.log("Retrieved base 64 image of length: ", result.image.length);
}, (error) => {
// Handle error
});
In your .js
file:
"use strict";
const config = {
'url': 'http://weather.yahoo.com',
'imageDir': './out/',
'verbose': true
};
const gs = require('./geoscreenshot')(config);
gs.locations().then(gs.multicapture)
.then((results) => {
console.log("Captured ", results.length, "locations");
}, (error) => {
// Handle error
});
node geoscreenshot
or
node geoscreenshot single <url>
node geoscreenshot random <url>
node geoscreenshot multi <url>
The script will generate 2 files per capture
<id>.json
, example:
{
"date": 1474044949580,
"id": "ws_0a986wrvn29_1474044949443",
"location": {
"name": "lv-rix-riga",
"city": "Riga",
"state": "RIX",
"country_code": "LV",
"country": "Latvia",
"lat": 56.95,
"lon": 24.1,
"plan": "plus",
"timezone": "Europe/Riga"
},
"request": {
"url": "http://www.example.com",
"viewport": "1336x1400",
"delay": "5",
"location": "lv-rix-riga",
"useragent": "chrome",
"fullpage": 0,
"no_images": 0,
"no_cache": 0
},
"size": 46284
}
and <id>.png
Note: As of 9/15/2016, GeoScreenshot API is still in beta, API access is disabled by default. To request access, send an email to contact@geoscreenshot.com with your use case and we will upgrade your account to have this feature
git clone https://github.com/geoscreenshot/geoscreenshot-api-example.git
npm install
Use a strong alphanumeric password generator for added security DO NOT store credentials in source code DO NOT re-use credentials you use for other accounts
export GS_API_BASE="" // Optional, custom for advanced users
export GS_USERNAME="<YOURUSERNAME>" // Username used on WebUI
export GS_PASSWORD="<ALPHANUMERICPASSWORD>" // Password used on WebUI
Check if it works
node geoscreenshot.js
The RESTful API is documented here: https://www.geoscreenshot.com/docs/
If you have a problem with this sample, please file an issue here. If you would like to contribute code you can do so through GitHub by forking the repository and sending a pull request.
Any issues related to API / Web Service, please send an email to contact@geoscreenshot.com. We are still in beta and appreciate all feedback.
Copyright 2016 TE Web Solutions
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
FAQs
Example for consuming basic operations of the GeoScreenshot web capture API. The example makes calls to the capture web service to retrieve capture data and stores the image as a PNG file. The simple use case captures Yahoo Weather for all available plus
The npm package geoscreenshot-api-example receives a total of 2 weekly downloads. As such, geoscreenshot-api-example popularity was classified as not popular.
We found that geoscreenshot-api-example demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.