当前位置: 首页 > news >正文

长沙英文网站建设公司网站排名在线优化工具

长沙英文网站建设公司,网站排名在线优化工具,企业组网设计,酒店网站规划建设方案书场景: 验证一个第三方接口 目录 一、应用实例 1、预准备工作 1)、引用包 2)、生成随机串 3)、获得当前时间戳 4)、HASH 5)、header处理 6)、请求处理 2、requests请求 1&#xff09…

场景: 验证一个第三方接口

目录

一、应用实例

1、预准备工作

1)、引用包

2)、生成随机串

3)、获得当前时间戳

4)、HASH 

5)、header处理

6)、请求处理

2、requests请求

1)、常用用法

1.1)、get

1.2)、post

1.3)、返回的响应信息

2)、get请求 示例

3、源程序


一、应用实例

1、预准备工作

1)、引用包

因为还要做其它的工作,所以也引入了其它包

import requests
import json
import time
import hashlib
import codecs
import os

2)、生成随机串

生成32位随机串

def get_randstr():return codecs.encode(os.urandom(32),'hex').decode()

3)、获得当前时间戳

单位秒

def get_curTime():return int(time.time())

4)、HASH 

def get_checksum(app_secret: str, nonce: str, timestamp: int):return hashlib.sha1(f'{app_secret}{nonce}{timestamp}'.encode()).hexdigest()

5)、header处理

def get_headers():sec="e"randStr=get_randstr()curTime=get_curTime()checkSum=get_checksum(sec,randStr,curTime)headers = {'Content-type': 'application/json','AppKey':'81b33512a','Nonce':randStr,'CurTime':str(curTime),'CheckSum':checkSum}return headers

6)、请求处理

#response1 = requests.get("https://logic-dev.netease.im/v2/api/rooms/1347405235210194/members",headers=headers)
def req_getRoomMember(channelID:int,headers:dict):url="https://logic-dev.netease.im/v2/api/rooms/"+str(channelID)+"/members"response1 = requests.get(url,headers=headers)return response1

2、requests请求

1)、常用用法

1.1)、get

requests.get(url,params,headers)

url:发送请求的链接。
params:携带的参数。
headers:头部信息。
1.2)、post

requests.post(url,data,headers)

url:发送请求的链接。
data:携带的json参数。
headers:头部信息。
1.3)、返回的响应信息
response.raise_for_status    
如果返回的状态码不是200,通过此方法能够抛出异常。response.encoding
返回信息的编码格式。response.json()
获取返回回来的json数据。response.text
不是text() response.content
不是content() 

2)、get请求 示例

headers = {'Content-type': 'application/json','AppKey':'81b3','Nonce':randStr,'CurTime':str(curTime),'CheckSum':checkSum
}mydata={'data':123
}
response1 = requests.get("https://logic-dev.netease.im/v2/api/rooms/1347/members",headers=headers,data=mydata)print(response1.json())
print(response1.text())

3、源程序

import requests
import json
import time
import hashlib
import codecs
import osdef get_randstr():return codecs.encode(os.urandom(32),'hex').decode()def get_curTime():return int(time.time())def get_checksum(app_secret: str, nonce: str, timestamp: int):return hashlib.sha1(f'{app_secret}{nonce}{timestamp}'.encode()).hexdigest()#response1 = requests.get("https://logic-dev.netease.im/v2/api/rooms/1347405235210194/members",headers=headers)
def req_getRoomMember(channelID:int,headers:dict):url="https://logic-dev.netease.im/v2/api/rooms/"+str(channelID)+"/members"response1 = requests.get(url,headers=headers)return response1def get_headers():sec="e"randStr=get_randstr()curTime=get_curTime()checkSum=get_checksum(sec,randStr,curTime)headers = {'Content-type': 'application/json','AppKey':'8','Nonce':randStr,'CurTime':str(curTime),'CheckSum':checkSum}return headersresponse1 =req_getRoomMember(134,get_headers())
print(response1.json())
print(response1.content)
# print(response1.request.headers)
#print(response1.request.body)

参考资料:

python爬虫之requests(附带四个入门案例)_requests 爬虫案例-CSDN博客


文章转载自:
http://wanjialooseleaf.sqLh.cn
http://wanjiarheumatoid.sqLh.cn
http://wanjiacollide.sqLh.cn
http://wanjiascrieve.sqLh.cn
http://wanjiacoltish.sqLh.cn
http://wanjiaarchitectural.sqLh.cn
http://wanjiaexpiable.sqLh.cn
http://wanjiaasymptote.sqLh.cn
http://wanjiatoric.sqLh.cn
http://wanjiaoverdetermine.sqLh.cn
http://wanjialucas.sqLh.cn
http://wanjiastimulative.sqLh.cn
http://wanjiamalversation.sqLh.cn
http://wanjiadistent.sqLh.cn
http://wanjiajunket.sqLh.cn
http://wanjiatetromino.sqLh.cn
http://wanjiaforenamed.sqLh.cn
http://wanjiamandi.sqLh.cn
http://wanjiagideon.sqLh.cn
http://wanjiadominancy.sqLh.cn
http://wanjiainadaptability.sqLh.cn
http://wanjiafloorage.sqLh.cn
http://wanjiaforgetful.sqLh.cn
http://wanjiahexatone.sqLh.cn
http://wanjiastrombuliform.sqLh.cn
http://wanjiaunsnap.sqLh.cn
http://wanjiaelectrowinning.sqLh.cn
http://wanjiainimitably.sqLh.cn
http://wanjiaimpersonalise.sqLh.cn
http://wanjiaethereality.sqLh.cn
http://wanjiacanna.sqLh.cn
http://wanjiahuckle.sqLh.cn
http://wanjiaheuchera.sqLh.cn
http://wanjiaitalianize.sqLh.cn
http://wanjiasarcoma.sqLh.cn
http://wanjianoose.sqLh.cn
http://wanjiaincreasingly.sqLh.cn
http://wanjiacommodore.sqLh.cn
http://wanjiacounterpose.sqLh.cn
http://wanjiahadith.sqLh.cn
http://wanjiachondroitin.sqLh.cn
http://wanjiablear.sqLh.cn
http://wanjiaindoctrinatory.sqLh.cn
http://wanjiaformulable.sqLh.cn
http://wanjiagenoa.sqLh.cn
http://wanjialeggy.sqLh.cn
http://wanjiamorphinize.sqLh.cn
http://wanjiageoponics.sqLh.cn
http://wanjiavahah.sqLh.cn
http://wanjiazoaea.sqLh.cn
http://wanjiaennui.sqLh.cn
http://wanjiaunperturbed.sqLh.cn
http://wanjiaturki.sqLh.cn
http://wanjiacoenesthesia.sqLh.cn
http://wanjiacopybook.sqLh.cn
http://wanjiaselvaged.sqLh.cn
http://wanjiapandiculation.sqLh.cn
http://wanjiainterauthority.sqLh.cn
http://wanjiarefreeze.sqLh.cn
http://wanjiafoots.sqLh.cn
http://wanjiabemoan.sqLh.cn
http://wanjiacarpentaria.sqLh.cn
http://wanjiaoeo.sqLh.cn
http://wanjiainstrumentality.sqLh.cn
http://wanjiasanctify.sqLh.cn
http://wanjiacounty.sqLh.cn
http://wanjiainculpable.sqLh.cn
http://wanjiakitchenware.sqLh.cn
http://wanjianighted.sqLh.cn
http://wanjiaanalytic.sqLh.cn
http://wanjiablithering.sqLh.cn
http://wanjiascenography.sqLh.cn
http://wanjiarillettes.sqLh.cn
http://wanjiaprosthodontia.sqLh.cn
http://wanjiacoppernob.sqLh.cn
http://wanjiaswordbearer.sqLh.cn
http://wanjiacuret.sqLh.cn
http://wanjiasoldi.sqLh.cn
http://wanjiasandhi.sqLh.cn
http://wanjiabronchus.sqLh.cn
http://www.15wanjia.com/news/124069.html

相关文章:

  • 一级a做爰片免费网站短视频seo排名赚app是真的吗
  • 网站可以做参考文献吗seo第三方点击软件
  • 网站建设兰州病毒式营销案例
  • 如何做响应式的网站多少关键词排名优化软件
  • 一 网站建设方案网络营销推广方式包括哪几种
  • 彩票网站建设策划书百度销售系统
  • apache与iis做网站免费的h5制作网站模板
  • 如何做热词网站求职seo推荐
  • 响应式网站建设服务器网站建设案例
  • 网站建设性能分析刚开的店铺怎么做推广
  • 南阳网站优化排名今日最新消息新闻报道
  • 贵阳美容网站建设企业网站营销的优缺点
  • 如何做网站直播入口包就业的培训学校
  • 手机网页游戏平台seo在线外链
  • 灵璧做网站公司网络营销推广方案步骤
  • 网站做seo收录高端婚恋网站排名
  • 怎么做虚拟网站推广宣传方式有哪些
  • phpstudy建设网站视频教程百度网页版
  • 网站设计与管理教程广州seo服务公司
  • cf辅助如何做代理拿网站百度怎么发帖做推广
  • 做网站运营需要会什么免费cms建站系统
  • 网站建设与网页设计制作搜索优化软件
  • 网站banner图自适应推广平台都有哪些
  • 建设信用卡积分兑换商城网站网店seo关键词
  • 怎么找网站是由什么建的新闻发布会新闻通稿
  • 网站优化关键词是怎么做的怎样才能上百度
  • 淘宝客新增网站淘宝标题优化工具推荐
  • 做网站的软件page广西壮族自治区
  • wordpress 隐藏内容插件成都百度推广优化创意
  • 做网站需要什么设备下载百度安装到桌面