# 1.导包from fastapi import FastAPI
from fastapi import Response
import uvicorn
# 2.创建对象
app = FastAPI()# 3.使用对象接收浏览器请求,并且使用对象给浏览器响应资源# 注意: get中传入请求的资源路径@app.get('/')deffunc():withopen('source/html/index.html','rb')as f:
data = f.read()
res = Response(data)return res
@app.get('/{html_name}')deffunc(html_name:str):withopen(f'source/html/{html_name}','rb')as f:
data = f.read()
res = Response(data)return res
@app.get('/images/{img_name}')deffunc(img_name:str):withopen(f'source/images/{img_name}','rb')as f:
data = f.read()
res = Response(data)return res
@app.get('/video/{vi_name}')deffunc(vi_name:str):withopen(f'source/video/{vi_name}','rb')as f:
data = f.read()
res = Response(data)return res
# 4.启动服务器(指定fastapi对象,主机地址,端口号)
uvicorn.run(app,host='192.168.86.44',port=9091)
爬取图片方式1:
核心知识点:
爬虫相关知识点
字符串切割方法: split()
正则表达式match匹配
列表的定义和遍历
if判断
枚举函数自动生成从0开始的编号: enumerate()
文件操作相关知识点
# 1.导包import requests
import re
# 2.准备要爬取数据的页面有效url
url ='http://192.168.86.44:9091/index.html'# 3.requests发送请求,获取响应对象
response = requests.get(url)# 4.content从响应对象中提取数据
html_str = response.content.decode()# print(html_str)# 5.正则表达式从页面数据中匹配所有图片路径# 把每一行放到列表中
html_list = html_str.split('\n')# print(html_list) # [' ']# 提前定义空列表用于存储图片路径
img_list =[]# 遍历列表依次匹配每一行数据for line in html_list:
data = re.match('.*, line)# 如果匹配成功,把路径存储起来if data:
img_list.append(data.group(1))# 循环外测试图片路径是否爬取到print(img_list)# 6.拼接图片url,并且批量发送请求
base_url ='http://192.168.86.44:9091'# 遍历图片路径列表for i, img_path inenumerate(img_list):# 拼接图片url
img_url = base_url + img_path[2:]# 发送请求获取响应对象
r = requests.get(img_url)# 从对象中获取资源
data = r.content
# 7.保存所有图片到本地withopen(f'load/{i}.jpg','wb')as f:
f.write(data)print(f"{i}.jpg保存成功!")
ArcgisEngine实现对地图的放大、缩小和平移:
个人觉得是平移,不过网上的都是漫游,通俗的说就是把一个地图对象从一边拉到另一边而已。就看人说话吧.
具体实现:
一、引入命名空间
using ESRI.ArcGIS.Geometry;
using ESRI.ArcGIS.Controls;
二、代码实现.
Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x.
You should preserve the original relative order of th