上传文件至 core/SNAPI
This commit is contained in:
57
core/SNAPI/WebFeed.py
Normal file
57
core/SNAPI/WebFeed.py
Normal file
@@ -0,0 +1,57 @@
|
||||
from ProjectCfg import DOMAIN
|
||||
from CallServer import _make_request
|
||||
|
||||
###==========================网页流==========================
|
||||
|
||||
def GetWebFeed(pubname:str,Authorization: str='') -> dict:
|
||||
"""获取网页流"""
|
||||
url = f"{DOMAIN}/publishers/{pubname}/feeds"
|
||||
headers = {'accept': 'application/json', 'Authorization': Authorization}
|
||||
return _make_request('GET', url, headers)
|
||||
|
||||
|
||||
def SendWebFeed(pubname:str,Authorization: str='',URL:str='',Title:str='',Description:str='',ScrapPage:bool=True) -> dict:
|
||||
"""发送网页流"""
|
||||
url = f"{DOMAIN}/publishers/{pubname}/feeds"
|
||||
RequestsBody={
|
||||
"url": URL,
|
||||
"title": Title,
|
||||
"description": Description,
|
||||
"config": {
|
||||
"scrap_page": ScrapPage,
|
||||
}
|
||||
}
|
||||
headers = {'accept': 'application/json', 'Authorization': Authorization}
|
||||
return _make_request('POST', url, headers,request_body=RequestsBody,normal_codes=[201])
|
||||
|
||||
def GetWebFeedDetail(feedid:str,pubname:str,Authorization: str='') -> dict:
|
||||
"""获取网页流详情"""
|
||||
url = f"{DOMAIN}/publishers/{pubname}/feeds/{feedid}"
|
||||
headers = {'accept': 'application/json', 'Authorization': Authorization}
|
||||
return _make_request('GET', url, headers)
|
||||
|
||||
def ModifyWebFeed(feedid:str,pubname:str,Authorization: str='',URL:str='',Title:str='',Description:str='',ScrapPage:bool=True) -> dict:
|
||||
"""修改网页流"""
|
||||
url = f"{DOMAIN}/publishers/{pubname}/feeds/{feedid}"
|
||||
RequestsBody={
|
||||
"url": URL,
|
||||
"title": Title,
|
||||
"description": Description,
|
||||
"config": {
|
||||
"scrap_page": ScrapPage,
|
||||
}
|
||||
}
|
||||
headers = {'accept': 'application/json', 'Authorization': Authorization}
|
||||
return _make_request('PATCH', url, headers,request_body=RequestsBody,normal_codes=[200])
|
||||
|
||||
def DeleteWebFeed(feedid:str,pubname:str,Authorization: str='') -> dict:
|
||||
"""删除网页流"""
|
||||
url = f"{DOMAIN}/publishers/{pubname}/feeds/{feedid}"
|
||||
headers = {'accept': 'application/json', 'Authorization': Authorization}
|
||||
return _make_request('DELETE', url, headers,normal_codes=[204])
|
||||
|
||||
def SetScrapPage(pubname:str,id:str,Authorization: str='') -> dict:
|
||||
"""设置是否采集网页"""
|
||||
url = f"{DOMAIN}/publishers/{pubname}/feeds/{id}/scrap"
|
||||
headers = {'accept': 'application/json', 'Authorization': Authorization}
|
||||
return _make_request('POST', url, headers,normal_codes=[201])
|
Reference in New Issue
Block a user