Created
May 1, 2017 17:33
-
-
Save ibaaj/4ad5089e2b6ee66a74b60cc4fa35cb4f to your computer and use it in GitHub Desktop.
Map My Feet
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 | |
import json | |
import csv | |
from requests.auth import HTTPBasicAuth | |
from time import strftime | |
USERNAME = "XXXXXXX" # icloud username | |
PASSWORD = "XXXXXXX" # icloud pass | |
auth = HTTPBasicAuth(USERNAME, PASSWORD) | |
headers = { | |
"Accept-Language": "en-us", | |
"Connection": "keep-alive", | |
"Content-Type": "application/json; charset=utf-8", | |
"User-agent": "Find iPhone/1.3 MeKit (iPad: iPhone OS/4.2.1)", | |
"X-Apple-Authscheme": "UserIdGuest", | |
"X-Apple-Find-Api-Ver": "2.0", | |
"X-Apple-Realm-Support": "1.0", | |
"X-Client-Name": "iPad", | |
"X-Client-UUID": "0cf3dc501ff812adb0b202baed4f37274b210853", | |
} | |
res = requests.post("https://fmipmobile.icloud.com/fmipservice/device/%s/initClient" % USERNAME, | |
auth=auth, data={}, headers=headers) | |
data = json.loads(res.text) | |
with open('/home/admin/location/location.csv', 'a') as f: | |
writer = csv.writer(f) | |
# first launch : create columns' names | |
#writer.writerow(["date","device","longitude","latitude","altitude"]) | |
for device in range(len(data["content"])): | |
n = data["content"][device]["deviceModel"] | |
lon = data["content"][device]["location"]["longitude"] | |
lat = data["content"][device]["location"]["latitude"] | |
alt = data["content"][device]["location"]["altitude"] | |
writer.writerow([strftime("%Y-%m-%d %H:%M:%S"), n, lon, lat, alt]) |
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
library(ggplot2) | |
library(ggmap) | |
data <- read.csv('location.csv') # cat location.csv | grep iphone >> lociphone.csv & change header | |
map <- get_map("Paris, France", zoom = 12, color="bw", maptype="satellite") | |
p <- ggmap(map, extent = "device") + geom_point(inherit.aes = FALSE, aes(x = data$lon, y = data$lat), | |
data = data, | |
colour = "red", | |
size = 1, | |
pch = 3 | |
) | |
p + ggsave ("map.png", dpi = 200) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment