mirror of
https://github.com/davidjohnbarton/crawler-google-places.git
synced 2025-12-12 16:38:45 +00:00
Set up input schema
This commit is contained in:
parent
347207129f
commit
29e07e02d0
33
INPUT_SCHEMA.json
Normal file
33
INPUT_SCHEMA.json
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
{
|
||||||
|
"title": "Crawler for Google places",
|
||||||
|
"type": "object",
|
||||||
|
"schemaVersion": 1,
|
||||||
|
"properties": {
|
||||||
|
"searchString": {
|
||||||
|
"title": "Search",
|
||||||
|
"type": "string",
|
||||||
|
"description": "String will be search on Google maps.",
|
||||||
|
"prefill": "New York Gym",
|
||||||
|
"editor": "textfield"
|
||||||
|
},
|
||||||
|
"lat": {
|
||||||
|
"title": "Viewport Latitude",
|
||||||
|
"type": "number",
|
||||||
|
"description": "Use it with combination with longitude and zoom to set up viewport to search on."
|
||||||
|
},
|
||||||
|
"lng": {
|
||||||
|
"title": "Viewport Longitude",
|
||||||
|
"type": "number",
|
||||||
|
"description": "Use it with combination with latitude and zoom to set up viewport to search on.",
|
||||||
|
},
|
||||||
|
"zoom": {
|
||||||
|
"title": "Viewport Zoom",
|
||||||
|
"type": "number",
|
||||||
|
"description": "Use it with combination with longitude and latitude to set up viewport to search on.",
|
||||||
|
"maximum": 15
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"searchString"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
@ -22,7 +22,6 @@ Example input:
|
||||||
On this input actor searches places on this start url: https://www.google.com/maps/search/%C4%8Dsob/@50.0860729,14.4135326,10z
|
On this input actor searches places on this start url: https://www.google.com/maps/search/%C4%8Dsob/@50.0860729,14.4135326,10z
|
||||||
|
|
||||||
- `searchString` - String will be search on Google maps
|
- `searchString` - String will be search on Google maps
|
||||||
- `searchViewport` - Object where user can define start view port for searching (Google will search places in this area)
|
- `lat` - Viewport latitude
|
||||||
- `searchViewport.lat` - Viewport latitude
|
- `lng` - Viewport longitude
|
||||||
- `searchViewport.lng` - Viewport longitude
|
- `zoom` - Viewport zoom, e.g zoom: 10 -> https://www.google.com/maps/@50.0860729,14.4135326,10z vs zoom: 1 -> https://www.google.com/maps/@50.0860729,14.4135326,10z
|
||||||
- `searchViewport.zoom` - Viewport zoom, e.g zoom: 10 -> https://www.google.com/maps/@50.0860729,14.4135326,10z vs zoom: 1 -> https://www.google.com/maps/@50.0860729,14.4135326,10z
|
|
||||||
|
|
|
||||||
1215
package-lock.json
generated
Normal file
1215
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
|
|
@ -30,16 +30,16 @@ const enqueueAllUrlsFromPagination = async (page, requestQueue) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
Apify.main(async () => {
|
Apify.main(async () => {
|
||||||
const { searchString, searchViewport } = await Apify.getValue('INPUT');
|
const { searchString, lat, lng } = await Apify.getValue('INPUT');
|
||||||
|
|
||||||
if (!searchString) throw new Error('Attribute searchString missing in input.');
|
if (!searchString) throw new Error('Attribute searchString missing in input.');
|
||||||
|
|
||||||
console.log('Scraping Google Places for search string:', searchString);
|
console.log('Scraping Google Places for search string:', searchString);
|
||||||
|
|
||||||
let startUrl;
|
let startUrl;
|
||||||
if (searchViewport) {
|
if (lat || lng) {
|
||||||
const { lat, lng, zoom = 10 } = searchViewport;
|
const { zoom = 10 } = input;
|
||||||
if (!lat || !lng) throw new Error('You have to defined lat and lng for searchViewport!');
|
if (!lat || !lng) throw new Error('You have to defined lat and lng!');
|
||||||
startUrl = `https://www.google.com/maps/@${lat},${lng},${zoom}z/search`;
|
startUrl = `https://www.google.com/maps/@${lat},${lng},${zoom}z/search`;
|
||||||
} else {
|
} else {
|
||||||
startUrl = 'https://www.google.com/maps/search/';
|
startUrl = 'https://www.google.com/maps/search/';
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user