apple_maps_api
Well, someone said that apple-map is unhackable! I said yes, let me try to scrap data (P.S.: I’m a noob, but I’m curious). I found that it is actually not. After a 100 times of stack-overflowing and shits, I did scrap apple-map and I’m sharing this code with you. Why am I sharing? cause I don’t give a fuck to these tiny little things in this world, neither the close source monopoly of things.
If you are confused with the documentation, please see this video, to see the scraping in action Apple Maps API to get enormous amount of satellite data for free using Python3.
Firstly remove satellite_data folder
$ sudo pip install -r requirements.txt
The api acess-key (which can be found out by selecting one tile from Apple Map, through chrome/firefox by going Developer->Network and then it is this part of the link &accessKey. dark) is valid for a period of 10-15 mins. You need to manually go to apple-map, get the API access key by pressing ctrl+shift+E and going to the network area. I tried to reverse engineer this thing but couldn’t. First part of the key is time in sec from 1970, but other part is some output of complex function which needs time to decipher. If anyone finds it, let me know, I’ll add you to the contributor’s section and may make this API fully automatic.
Need for hacking and scraping satellite data
Well it’s good (best in the world) satellite images, we just need to give the coordinates (Lat,Lon, and zoom) to get your dataset of high resolution satellite images! Create your own dataset and apply ML algorithms :’)
Some of the example images downloaded :
The scraping API is present, call it and download it.
>>from satcdnApplScrap import api >>a=api() # Change the access key here # give the (min_lat,max_lat,min_lon,max_lon,access_key) in this function # note the access key is manually changed all the time here! >>a.download_images(40,40.5,40,40.5,'&accessKey=1549375931_5723979149709274034_%2F_iOwwf%2B70uM1bJHAEcHbkhV9zbC3RUKbTCT3LEtkJQa8%3D&emphasis=standard&tint=dark',4) 100%|██████████████████████████████████████████████████████████████ | 1000/10000000 [00:02
Well I'm not that bad. This is done through parallel proccessing, so this will take all the thread in your CPU, change the code to your own requirements! This is done so that you could download about 40K images in 30 mins! (That's fuckin fast. )
Please move this data after every fetch request done! Else you won't get the updated information (tiles) of satellite data after that tile. It is calculated automatically so that all the progress remains saved!
This also uses multithreading, which may overload your computer, so set the parameters in the API, minimise the pool else your PC may hang!
Cookies help us deliver our services. By using our services, you agree to our use of cookies Learn more
mapsnap - Apple Maps Web Snapshots on Python
If you want to dig deeper on the attributes and parameters of the returned instance you just need to take a look at its representation by either calling it directly on the Python REPL or by calling repr() over it like so:
, poi=None, lang='en-US', annotations=None, overlays=None, referer=None, expires=None, imgs=None)"
Notice that the _key, teamId and keyId attributed are always nullified by design before returning the instance for security purposes (try to prevent exposure of the key content and IDs).
You can also call the .png() method which returns a PNG file object. The sample below shows how you can fetch the PNG image directly and write it to a file:
and alas, we have a map image:
You can later convert the PNG file to other formats using an image module like Pillow.
Installing & Updating
mapsnap is available on PyPI and can be installed or updated with:
If you're having installation problems due to ecdsa gmpy2 dependency, try installing the libgmp, libmpfr and libmpc:
- (mac) - brew install gmp mpfr libmpc mpc
- (linux) - sudo apt install -y libgmp-dev libmpfr-dev libmpc-dev
Setup
- First you need to head to your Apple Developer Account
- Then Go to Certificates, Identifiers & Profiles
- Click on Keys on the left menu
- Click the + Sign next to Keys
- Choose a name for your new Apple MapKit JS Key
- Mark the MapKit JS checkbox and Configure it
- Click Continue
- Click on Register at the top right
- Download your key and store it safely. Take Note of your Key ID
- Sometimes the .p8 keys works out of the box. If you're having signing issues, than try the next steps. First try to use the .p8 key you have downloaded directly from apple as the _key parameter.
- You can do that using either:
- $ openssl ec -in __[PATH_TO_ORIGINAL_KEY.p8]__ -out __[PATH_TO_OUTPUT_PEM_KEY.pem]__
- $ openssl pkcs8 -nocrypt -in __[PATH_TO_ORIGINAL_KEY.p8]__ -out __[PATH_TO_OUTPUT_PEM_KEY.pem]__
Usage
You just need to import the MapSnap class and instance it. you should also import utilities that you will need to use like Annotations, Colors and others.
Every time you create a new instance of this class, a signed URL is automatically generated and you can access it directly over the instance .url attribute or download the PNG from Apple for usage as a regular Python file object by calling the .png() method on the instance itself.
Customizing the Maps
Adding Annotations (Markers)
Default Parameters and Attributes
Parameter Type Description _key str or bytes The path for the .p8 or .pem file containing your MapKit JS Key downloaded from Apple Developer Portal. (ex: /opt/myapplekeys/AuthKey_XXXXXXXXXX.p8)
This can also be a bytes object containing the raw contents of the key file.teamId str Your Apple Developer Team ID (you can view it on https://developer.apple.com after logging in near your company/developer name or by accessing the Membership option on the menu) keyId str This ID is shown to you when you create your key and is generally part of the key file name, for instance if the downloaded key file is AuthKey_XYZ712387.p8 your keyId is XYZ712387. (You can double check it by going to your details on the Apple Developer portal) The rest of the parameters are mapped directly from Apple Maps Web Snapshots documentation and can be used as guided there.
I have tried to map as much as possible as dataclasses that can be imported from this module itself as shown in examples.
If you want to set a value for a parameter, you can check the mapped values currently implemented on /mapsnap/utils.py
Requirements
mapsnap requires Python 3.7 os higher since it uses dataclasses.
- Python 3.7 (or higher)
- ecdsa[gmpy2] ( pip install ecdsa[gmpy2] )
- requests ( pip install requests )
References
Authors
Contributing
- Follow the PEP8 specification
- Write and Run Tests
- Make sure to run pre-commit hooks
LICENSE
This project is licensed under the MIT License - see the LICENSE file for details.
DISCLAIMERS AND TRADEMARKS
Apple, Apple Maps, MapKit and iOS are registered trademarks of Apple Inc.
The Apple Maps Web Snapshots are currently considered Beta Software and subject to change.
Copyright (c) 2020 Ygor Lemos
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
jimutmap
This manually brute forces apple-map. It Then scraps all the tiles as given by the parameters provided by the user.
YouTube video :
If you are confused with the documentation, please see this video, to see the scraping in action Apple Maps API to get enormous amount of satellite data for free using Python3.
Installation
sudo pip install jimutmap
Pypi
Works in Colab too!
The api acess-key (which can be found out by selecting one tile from Apple Map, through chrome/firefox by going Developer->Network and then it is this part of the link &accessKey. dark) is valid for a period of 10-15 mins. You need to manually go to apple-map, get the API access key by pressing ctrl+shift+E and going to the network area. I tried to reverse engineer this thing but couldn't. First part of the key is time in sec from 1970, but other part is some output of complex function which needs time to decipher. If anyone finds it, let me know, I'll add you to the contributor's section and may make this API fully automatic.
Need for hacking and scraping satellite data
Well it's good (best in the world) satellite images, we just need to give the coordinates (Lat,Lon, and zoom) to get your dataset of high resolution satellite images! Create your own dataset and apply ML algorithms :')
Some of the example images downloaded :
The scraping API is present, call it and download it.
Well I'm not that bad. This is done through parallel proccessing, so this will take all the thread in your CPU, change the code to your own requirements! This is done so that you could download about 40K images in 30 mins! (That's fuckin fast. )
Please move this data after every fetch request done! Else you won't get the updated information (tiles) of satellite data after that tile. It is calculated automatically so that all the progress remains saved!
Note
This also uses multithreading, which may overload your computer, so set the parameters in the API, minimise the pool else your PC may hang!
fcrespo82 / SearchGooglePlaces.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- import requests , json , webbrowser , urllib , sys API_KEY = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' # Get your api key from https://code.google.com/apis/console/, you MUST add the Places API permission to it GOOGLE_PLACES_URI = 'https://maps.googleapis.com/maps/api/place/textsearch/json?query=&sensor=false&key=' APPLE_MAPS_URI = 'safari-http://maps.apple.com/?q=' #call this script in pythonista for ios pythonista://GoogleToAppleMaps?action=run&argv=[prompt] def main (): if len ( sys . argv ) < 2 : print ( 'You must send the serch term as the first argument of this script' ) else : search_term = sys . argv [ 1 ] r = requests . get ( GOOGLE_PLACES_URI . format ( search_term , API_KEY )) contents = json . loads ( r . content ) if r . status_code == requests . codes . ok : print ( 'Place search success' ) # Search successful get first result first = contents [ 'results' ][ 0 ] #name = first['name'] #latlong = first['geometry'] address = first [ 'formatted_address' ]. encode ( 'utf-8' ) print ( address ) webbrowser . open ( APPLE_MAPS_URI . format ( urllib . quote ( address ))) else : print ( 'Error obtaining place' ) if __name__ == '__main__' : main ()