下载百度街景照片

参考网页:http://www.archcollege.com/archcollege/2017/09/37296.html

上面的网页介绍的很详细,,根据需求对代码进行了改动,设定了一些方向角度,如下:

import requests
import os
from selenium import webdriver

def save_photo(root,url):
   if not os.path.exists(root):
       os.makedirs(root) #若没有街景图片文件夹则自动创建
   #m = url.split("&")[3] + " + " + url.split("&")[5] + " + " + url.split("&")[6] + ".jpeg" #把经纬度和方向作为街景的名称
   m = url.split("&")[3] +  ".jpg" #把经纬度和方向作为街景的名称
   name = root + m
   r = requests.get(url)
   with open(name, "wb") as f:
       f.write(r.content)
       f.close()
       print("您选择的街景已经成功保存至E盘街景图片文件夹!感谢您的使用!nnn")
           #来自WSSD设计的编译

while True:
   #start = input("【控制界面】n输入【1】软件正常运行,输入【0】软件将结束运行!n")
   #if start == "0":
       #print("感谢您使用百度街景下载器,来自WSSDS设计!")
       #break
   #ak = input("请输入您获取的百度秘钥AK:n")
   #a = webdriver.Chrome()
   #a.get("http://api.map.baidu.com/lbsapi/getpoint/index.html")
   location = input("【坐标设置】n请输入您拾取的坐标(格式:经度,纬度):n")
   heading = input("请输入您需要的全景的方向角度(0-360):n")
   pitch = input("请输入您需要的全景的垂直角度(0-360):n")
   url = "http://api.map.baidu.com/panorama/v2?ak=gzOaygrAQDXngj4RRtERVFC6cIrnSCk5&width=1024&height=512&location=" + location + "&fov=90&heading=" + heading + "&pitch=" + pitch
   root = "E://街景图片//"  # 文件保存位置
   save_photo(root,url)

猜你喜欢

转载自blog.csdn.net/qq_34585338/article/details/90703896
今日推荐