python秒网课_职教云网课进度分析(秒网课)+批量获取CellID的python代码

本文介绍了一个使用Python编写的脚本,该脚本能够完成职教云网课的模块加载、话题列表获取以及子节点CellID的批量获取。通过调用API,脚本可以详细分析网课的进度情况,为教学管理和学习辅助提供便利。
摘要由CSDN通过智能技术生成

[Python] 纯文本查看 复制代码import random

import time

import requests

def get_all():

url = 'https://zjyapp.icve.com.cn/newmobileapi/assistTeacher/getModuleListByClassId'

data = {

'courseOpenId': 'courseOpenId',

'openClassId': 'courseOpenId',

'stuId': 'stuId',

}

html = requests.post(url=url, data=data).json()

data = html['moduleList']

moduleIds = []

for i in data:

print(i['moduleName'] + '已加载')

moduleIds.append(i['moduleId'])

return moduleIds

def get_list(moduleId):

url = 'https://zjy2.icve.com.cn/newmobileapi/assistTeacher/getTopicListByModuleId'

moduleIds = []

for i in moduleId:

data = {

'openClassId': 'openClassId',

'courseOpenId':

  • 1
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
如果您在使用 `s2sphere` 库的 `CellId` 对象时遇到 "‘CellId’ object has no attribute 'get_coverer'" 错误,这是因为 `CellId` 对象本身没有 `get_coverer` 方法。 要使用 `s2sphere` 库中的 `S2RegionCoverer` 类来获取矩形区域内的S2单元格,您可以按照以下步骤进行操作: 1. 导入所需的库和模块: ```python import shapefile from s2sphere import CellId, LatLngRect, LatLng, S2RegionCoverer ``` 2. 定义矩形区域的边界坐标: ```python min_lat = 40.0 # 最小纬度 max_lat = 41.0 # 最大纬度 min_lng = -74.0 # 最小经度 max_lng = -73.0 # 最大经度 ``` 3. 创建一个Shapefile写入器: ```python shp_writer = shapefile.Writer("cells", shapeType=shapefile.POLYGON) shp_writer.field("CELL_ID", "C", size=50) ``` 4. 使用 `S2RegionCoverer` 类获取矩形区域内的所有S2单元格: ```python rect = LatLngRect.from_point_pair( LatLng.from_degrees(min_lat, min_lng), LatLng.from_degrees(max_lat, max_lng) ) coverer = S2RegionCoverer() covering = coverer.get_covering(rect) ``` 5. 遍历每个S2单元格并将其添加到Shapefile中: ```python for cell_id in covering: cell = CellId(cell_id).to_lat_lng_rect() # 获取单元格的四个顶点坐标 vertices = [ (cell.get_vertex(i).lat().degrees, cell.get_vertex(i).lng().degrees) for i in range(4) ] # 添加多边形 shp_writer.poly(parts=[vertices]) shp_writer.record(str(cell_id)) ``` 6. 保存Shapefile文件: ```python shp_writer.save("cells") ``` 完整的示例代码如下: ```python import shapefile from s2sphere import CellId, LatLngRect, LatLng, S2RegionCoverer min_lat = 40.0 # 最小纬度 max_lat = 41.0 # 最大纬度 min_lng = -74.0 # 最小经度 max_lng = -73.0 # 最大经度 shp_writer = shapefile.Writer("cells", shapeType=shapefile.POLYGON) shp_writer.field("CELL_ID", "C", size=50) rect = LatLngRect.from_point_pair( LatLng.from_degrees(min_lat, min_lng), LatLng.from_degrees(max_lat, max_lng) ) coverer = S2RegionCoverer() covering = coverer.get_covering(rect) for cell_id in covering: cell = CellId(cell_id).to_lat_lng_rect() vertices = [ (cell.get_vertex(i).lat().degrees, cell.get_vertex(i).lng().degrees) for i in range(4) ] shp_writer.poly(parts=[vertices]) shp_writer.record(str(cell_id)) shp_writer.save("cells") ``` 运行该代码后,将生成一个名为 "cells.shp" 的Shapefile文件,其中包含了矩形区域内的所有S2单元格,并以单元格ID为属性。您可以使用GIS软件(如QGIS)打开和查看生成的Shapefile文件。 请确保您已经正确安装了 `s2sphere` 库,并且按照以上步骤进行操作。如果问题仍然存在,请提供更多详细信息,我将尽力帮助您解决问题。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值