人妖在线一区,国产日韩欧美一区二区综合在线,国产啪精品视频网站免费,欧美内射深插日本少妇

新聞動態(tài)

女友半夜加班發(fā)自拍 python男友用30行代碼發(fā)現(xiàn)驚天秘密

發(fā)布日期:2022-02-08 16:37 | 文章來源:源碼之家

事情是這樣的

正準(zhǔn)備下班的python開發(fā)小哥哥

接到女朋友今晚要加班的電話

并給他發(fā)來一張背景模糊的自拍照

如下 ↓ ↓ ↓

敏感的小哥哥心生疑竇,難道會有原諒帽

然后python擼了一段代碼 分析照片

分析下來 emmm

拍攝地址居然在 XXX酒店

小哥哥崩潰之余 大呼上當(dāng)

python分析照片

小哥哥將發(fā)給自己的照片原圖下載下來

并使用python寫了一個腳本

讀取到了照片拍攝的詳細(xì)的地址

詳細(xì)到了具體的街道和酒店名稱

引入exifread模塊

首先安裝python的exifread模塊,用于照片分析

pip install exifread 安裝exfriead模塊

PS C:\WINDOWS\system32> pip install exifread
Collecting exifread
  Downloading ExifRead-2.3.2-py3-none-any.whl (38 kB)
Installing collected packages: exifread
Successfully installed exifread-2.3.2
PS C:\WINDOWS\system32> pip install json

GPS經(jīng)緯度信息

其實我們平時拍攝的照片里,隱藏了大量的私密信息

包括 拍攝時間、極其精確 具體的GPS信息。

下面是通過exifread模塊,來讀取照片內(nèi)的經(jīng)緯度信息。

#讀取照片的GPS經(jīng)緯度信息
def find_GPS_image(pic_path):
 GPS = {}
 date = ''
 with open(pic_path, 'rb') as f:
  tags = exifread.process_file(f)
  for tag, value in tags.items():
#緯度
if re.match('GPS GPSLatitudeRef', tag):
 GPS['GPSLatitudeRef'] = str(value)
#經(jīng)度
elif re.match('GPS GPSLongitudeRef', tag):
 GPS['GPSLongitudeRef'] = str(value)
#海拔
elif re.match('GPS GPSAltitudeRef', tag):
 GPS['GPSAltitudeRef'] = str(value)
elif re.match('GPS GPSLatitude', tag):
 try:
  match_result = re.match('\[(\w*),(\w*),(\w.*)/(\w.*)\]', str(value)).groups()
  GPS['GPSLatitude'] = int(match_result[0]), int(match_result[1]), int(match_result[2])
 except:
  deg, min, sec = [x.replace(' ', '') for x in str(value)[1:-1].split(',')]
  GPS['GPSLatitude'] = latitude_and_longitude_convert_to_decimal_system(deg, min, sec)
elif re.match('GPS GPSLongitude', tag):
 try:
  match_result = re.match('\[(\w*),(\w*),(\w.*)/(\w.*)\]', str(value)).groups()
  GPS['GPSLongitude'] = int(match_result[0]), int(match_result[1]), int(match_result[2])
 except:
  deg, min, sec = [x.replace(' ', '') for x in str(value)[1:-1].split(',')]
  GPS['GPSLongitude'] = latitude_and_longitude_convert_to_decimal_system(deg, min, sec)
elif re.match('GPS GPSAltitude', tag):
 GPS['GPSAltitude'] = str(value)
elif re.match('.*Date.*', tag):
 date = str(value)
 return {'GPS_information': GPS, 'date_information': date}

百度API將GPS轉(zhuǎn)地址

這里需要使用調(diào)用百度API,將GPS經(jīng)緯度信息轉(zhuǎn)換為具體的地址信息。

這里,你需要一個調(diào)用百度API的ak值,這個可以注冊一個百度開發(fā)者獲得,

當(dāng)然,你也可以使用博主的這個ak

調(diào)用之后,就可以將拍攝時間、拍攝詳細(xì)地址都解析出來。

def find_address_from_GPS(GPS):
 secret_key = 'zbLsuDDL4CS2U0M4KezOZZbGUY9iWtVf'
 if not GPS['GPS_information']:
  return '該照片無GPS信息'
 #經(jīng)緯度信息
 lat, lng = GPS['GPS_information']['GPSLatitude'], GPS['GPS_information']['GPSLongitude']
 baidu_map_api = "http://api.map.baidu.com/geocoder/v2/?ak={0}&callback=renderReverse&location={1},{2}s&output=json&pois=0".format(
  secret_key, lat, lng)
 response = requests.get(baidu_map_api)
 #百度API轉(zhuǎn)換成具體的地址
 content = response.text.replace("renderReverse&&renderReverse(", "")[:-1]
 print(content)
 baidu_map_address = json.loads(content)
 #將返回的json信息解析整理出來
 formatted_address = baidu_map_address["result"]["formatted_address"]
 province = baidu_map_address["result"]["addressComponent"]["province"]
 city = baidu_map_address["result"]["addressComponent"]["city"]
 district = baidu_map_address["result"]["addressComponent"]["district"]
 location = baidu_map_address["result"]["sematic_description"]
 return formatted_address,province,city,district,location
 
if __name__ == '__main__':
 GPS_info = find_GPS_image(pic_path='C:/女友自拍.jpg')
 address = find_address_from_GPS(GPS=GPS_info)
 print("拍攝時間:" + GPS_info.get("date_information"))
 print('照片拍攝:' + str(address))

Python小哥得到的結(jié)果是這樣的

照片拍攝地址:('云南省XXXXXXX縣', '云南省', 'XXXX市', 'XXX縣', 'XXXX酒店')

云南彌勒XXXX酒店,這明顯不是老王女友工作的地方

小哥哥搜索了一下,這是一家溫泉度假酒店。

頓時就明白了

完整代碼:點此下載

到此這篇關(guān)于女友半夜加班發(fā)自拍 python男友用30行代碼發(fā)現(xiàn)驚天秘密的文章就介紹到這了,更多相關(guān)python讀取GPS內(nèi)容請搜索本站以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持本站!

海外穩(wěn)定服務(wù)器

版權(quán)聲明:本站文章來源標(biāo)注為YINGSOO的內(nèi)容版權(quán)均為本站所有,歡迎引用、轉(zhuǎn)載,請保持原文完整并注明來源及原文鏈接。禁止復(fù)制或仿造本網(wǎng)站,禁止在非www.sddonglingsh.com所屬的服務(wù)器上建立鏡像,否則將依法追究法律責(zé)任。本站部分內(nèi)容來源于網(wǎng)友推薦、互聯(lián)網(wǎng)收集整理而來,僅供學(xué)習(xí)參考,不代表本站立場,如有內(nèi)容涉嫌侵權(quán),請聯(lián)系alex-e#qq.com處理。

相關(guān)文章

實時開通

自選配置、實時開通

免備案

全球線路精選!

全天候客戶服務(wù)

7x24全年不間斷在線

專屬顧問服務(wù)

1對1客戶咨詢顧問

在線
客服

在線客服:7*24小時在線

客服
熱線

400-630-3752
7*24小時客服服務(wù)熱線

關(guān)注
微信

關(guān)注官方微信
頂部