爬虫:使用Requests模块基本使用_response=requests.port(-程序员宅基地

技术标签: 爬虫  request  python  urllib  爬虫【python】  

 

目录

安装Requests

示例引入

GET请求

抓取网页

抓取二进制数据

 POST请求

常用的响应

我们了解urllib的基本用法,但是其中确实有不方便的地方,比如处理网页验证和 ookies时,需要写 Opener 和Handler来处理.。为了更加方便地实现这些操作,就有了更为强大的库request ,有了它, Cookies 、登录验证、代理设置等操作都不是事儿。

安装Requests

pin install requests

示例引入

import requests

response = requests.get("https://www.baidu.com")
print(type(response))
print(response.status_code)
print(type(response.text))
print(response.text)
print(response.cookies)

结果
<class 'requests.models.Response'>
200
<class 'str'>
<!DOCTYPE html>
<!--STATUS OK--><html> <head><meta http-equiv=content-type content=text/html;charset=utf-8><meta http-equiv=X-UA-Compatible content=IE=Edge> </div> </div> </div> </body> </html>

<RequestsCookieJar[<Cookie BDORZ=27315 for .baidu.com/>]>

这里我们调用 get() 方法实现与 urlopen() 相同的操作,得到一个 Response 对象,然后分别输出 Response 的类型、状态码、响应体的类型、以及内容 及Cookies

通过运行结果可以发现,它的返回类型是 requests.models .Response 响应体的类型是字符串str, Cookies 的类型是Req uestsCookieJar

GET请求

HTTP中最常见的请求之一就GET是请求,下面首先来详细了解一下利用 Requests 构建 GET 请求的方法
 

import requests

data = {
    "age":22,
    "name":"python"
}

reponse = requests.get("http://192.168.1.104/get",params=data)
print(type(reponse.text))
print(reponse.json())
print(type(reponse.json()))

结果:
<class 'str'>
{'args': {'age': '22', 'name': 'python'}, 'headers': {'Accept': '*/*', 'Accept-Encoding': 'gzip, deflate', 'Connection': 'keep-alive', 'Host': '192.168.1.104', 'User-Agent': 'python-requests/2.25.1'}, 'origin': '192.168.1.101', 'url': 'http://192.168.1.104/get?age=22&name=python'}
<class 'dict'>

可以发现调用json()方法,就可以将返回结果是JSON格式的字符串转化为字典,但需要注意的是,如果返回结果不是 JSON 式,便会出现解析错误,抛出 json.decoder. JSONDecodeError 异常

抓取网页

上面的请求链接返回的是 JSON 形式的字符串, 那么如果请求普通的网页,则肯定能获得相应的内容了

import requests
import re

headers = {
    "User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.45 Safari/537.36"
}
reponse = requests.get("https://www.zhihu.com/explore",headers=headers)
pattern = re.compile('"ExploreSpecialCard-contentTitle".*?.data-za-detail-view-id="5794"*?>(.*?)</a>',re.S)
title = re.findall(pattern,reponse.text)
print(title)


结果:
['提示一:成为风险管理者', '时间旅人:上知乎的穿越者能透露一点未来的事吗?', '「保险」到底保险吗?', '【答案年终秀】本届天团向知乎网友问好', '你认为中国青年准备好走向世界舞台中央了吗?', '如何评价现在的大学生?', '哪些细思极恐的行为会让你感染HPV?', '哪些细思极恐的行为会让你感染HPV?', '接种 hpv 疫苗时,有哪些注意事项?', '长寿时代,不少人成了「困在长寿里的人」,该如何破局?', '健康问题让你对生活做出了哪些妥协?', '如何拥有一个充实而又愉快的老年生活?']

这样就可以提取其中的文本信息了

抓取二进制数据

在上面的例子中,我们抓取的是知乎的一个页面 实际上它返回的是 HTML 文档 如果想抓取图片、音频、 视频等文件,应该怎么办呢?

图片、音频、视频这些文件本质上都是由二进制码组成的,由于有特定的保存格式和对应的解析方式, 我们才可以看到这些形形色色的多媒体 所以,想要抓取它们,就要拿到它们的二进制码

import requests


headers = {
    "User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.45 Safari/537.36"
}
reponse = requests.get("https://static.zhihu.com/heifetz/favicon.ico",headers=headers)
print(reponse.text)
print(reponse.content)

结果;
           ¨     (       @                                     �e `�g Ώ�e ώ�f ��f ��f��f ��f ��f ��f ��f ��f ��f ��f ��fώ�f��f��e ��f ��fώ�g ώ�j��k ��lξ�o Ώ�q _                �` �f Ο�e ώ�f ��f ��e ώ�f ��f ��f ��f ��fώ�eώ�f��e ��fώ�f��f ��f ��f��f ��g��h ��i ��k ��l ��n ��p ��q ώ�t Ώ�p         �eΏ�eώ�f ��f ��f��f ��f ��f ��f ��f ��f ��f ��f ��g��f ��fώ�f ��f ��f ��g ��h ώ�j ��l ��lώ�n ��p ��r ��s ��u ��w Ο    �f _�f ��f ��fώ�f ��f ��f��f ��e ώ�f��fώ�e ώ�f ��eώ�e ώ�fώ�eώ�f ��f��g ��i ��j ��l ��n ��o ��p ��qώ�t ��u ��v ��x��y _�g Ώ�e ��f��f ��f ��f ��f ��f ��e ώ�e ώ�f ��f ��f��f ��f ��f ��f��g��g ��i ��k ��l ��n��oώ�p ώ�r��s ��u ώ�v ��x ��y ώ�{ Ώ�fξ�f��f ��e ώ�f���@���`���@��f ��e ώ�eώ�f��f ��e ώ�f ��e ώ�fώ�h ��i ��k ��lώ�m ώ�o ��qώ�s ��sώ�u ώ�v ��y ��z ��{ώ�}��f ��fώ�e ��f ��e ώ� `��υο������ΨΏ��y ώ�f ��f ��f��e ώ�f��Ε ��h ��j��k ��lώ�Ι ��”@��q ��s ��t ��v��w ��x ώ�z ��{ ��}ώ� ��e ώ�f��f ��f ��f ��f ��‚0��υο������μί��f ��fώ�e ώ�f ��p������s��l ��m ��n ��φο������Β���}��uώ�x ��y ��z ώ�|��}ώ�€��€ ��f ��f ώ�f ��f ��f ��f ��f ���`����������³€ώ�eώ�f ��z!��υο������~ ��¤`��������������������������������������| ώ�~��€ ��€ ώ�‚ ώ�e ώ�f ��f��f��e ��f��fώ�f ��Ε ������μί��y ��g ��ΩΏ������ΪΏ��m��¥`��������������—@��Υ―������������������~ ��€��€ώ�‚ ώ�„��f ��f ��f ��f ��f ��f ��f��fώ�x!ώ���������΅`��¬pώ�����φο��€ ώ�o ώ�¦`������άΏ��u ��vώ�x ��z ��‹ ����������€ ���ώ�‚ώ�„ ��… ��f ��f ��e ώ�f��g��f ��eώ�f ��f ��Ζ ������ΪΏ��μί������p��p ��q ��§`������έΏ��w ώ�y ��yώ�| ���!ώ���������‚ ��ƒ ��… ��† ��� ��fώ�f ��f ��f ��f ��f��e ώ�f ��g ���@ώ�����φο�� ��ΐ���p ��qώ�s ��¨`������ήΏ��y ��z ώ�|��~��� ����������ƒ ��… ��‡�����‰ ��fώ�f ��f ��f ��f��f ��f ��f ώ�hώ�j ��φο������‰1ώ�p��q ��s ��tώ�`������ήΏ��{��}��} ώ� ��‘!ώ���������…��‡���ώ�� ���ώ�f��fώ�fώ�f ��f��p��z!ώ�{ ώ�} ��~ ��δΟ�������P��qώ�s ��u ��v ��«aώ�����ήΏ��} ��~ �� ��€ώ�’ ����������‡ ��‰��‰ ώ�‹ ώ��ώ�f ��f��fώ�f ��fώ�½�������������������������������������������ξί��­`ώ�����ίΏ��~��€ώ�� ��ƒ ��” ����������‰������������ ��f ��f��fώ�f ��h ��| ��ΪΏ��μί��νί��νί��φο������χο��ξί��ξί��οί��Ξ���­`������ίΏ��€��� ��ƒ ��„ ώ�• ����������‹��� ������ ��‘ ώ�f��f ��g ��i ��i ��k ��m��n ώ�p ��q ��Ή€������Λ���w ��y��z ώ�{ ��`������ΰΏ��‚ ��ƒώ�… ��†ώ�—!ώ���������� ώ�� ��� ��‘ ��“ώ�f ��g ��i��j ��l ��m ��o ��p ��r ��s ��Ή€������Μ���y ��{��| ��~ ��―`������ΰΏ��„ ��… ��‡ ��‡ώ�� ����������� ��� ώ�‘��“ώ�” ��g ��i��jώ�lώ�m ��›P��―pώ�zώ�t��u ��Ί€������Ν���{ ��|ώ�~ ��€ ��°a������ΰΏ��… ��‡ ώ�� ���ώ�� ����������� ��’ ��“ ��” ��— ώ�i ��j ��l ��m ��o ��”@������ξί��‡ ��w��Ό€������Ξ���| ��~ ��€ ��� ��±`������ΰΏ�����‰ ��� �����› ����������’��“��• ��—ώ�� ��j ώ�m��n��p��q ��r ��άΏ������Γ���xώ�Ό€������Ο���~ ��€��� ��ƒώ�²`������αΏ��‰��� ��� ��� ��� ����������”��• ��—ώ�� ��� ��lώ�nώ�p ��q ��s ��t ώ�`������χο��ήΏ��οί������χο��ίΏ��ίΏ��ίΏ��³`��³a������χο��αΏ��γΏ��γΏ��γΏ��γΏ����������• ��— ώ�� ��� ��› ��n ��p ��q ��s ώ�u ��v ��� ��������������������������������������΄`��΄`��������������������������������������� ώ���� ��� �����q ��qώ�s ��u ��v ��x ��yώ�Φ―������Η��� @ώ�΅@��΅@��£@ώ�¤@��¥@��‰��‘��@���@��«@��¬@��­@��@��―@��°@��²@�� ��› ώ����� ώ�� ��r ��t��u ��v ��xώ�y ώ�{��­`������ηΟ��� ��‚ ��…��†��‡ ώ�‰ ��� ώ�� ��� ��� ��� ��’ώ�“ ��–ώ�– ��� ��� ώ�› ������ ώ�� ��΅ ��t ��u��w ��x ��z��{ ��} �� ��·p��χο��“ ώ�„ ��… ��‡ ��� ώ�‹ ������ ��� ��‘��’��” ��• ��—ώ��ώ�� ��›������ ��  ώ�΅ ��£ ο�wΏ�w ��y ��zώ�{ ��} �� ��€ ��‚��„ ��… ��† ώ�‡ώ�‰ ��‹ώ�� ���ώ�� ��‘ώ�“ ��•ώ�• ��— ��� ��� ������ �����  ��Ά��£��¤ Ώ�x `�y��z ��|��~��€ ��€ ��‚��ƒ ��… ώ�†��� ��� ��‹��� ��� ��� ��‘ ��“ ��• ��–ώ�— �� ��› ώ��ώ����� ��  ��Ά��£ ��¥ ��¦ _    �zΟ�| ��~ώ�€��� ��‚��ƒώ�†��† ώ��ώ��ώ�‹ώ�� ��� ώ�� ώ�‘ ��“ ώ�• ��— ώ�— �� ��� ��� ���ώ�� ��΅ ��Ά��¤ώ�¥ ��§ Ώ        �€ �} Ώ�€ώ�� ��ƒ ��„ώ�… ��‡��‰��� ��‹ ���ώ�� ��� ��’ώ�” ώ�” ��– ��� �� ��› ��� ��� �����΅��Ά��£ ��¥ ��§ Ο��                 �� _�ƒ Ώ�„ ο�… ώ�‡ ��‰ώ�� ��� ��� ���ώ�� ��’��”��• ��— ��� ���ώ�› ���ώ�� ��� ��΅ ��£��¤ ��¥ Ώ�¦ _            ΰ  €  €                                                                                                          €  €  ΰ  
b'\x00\x00\x01\x00\x01\x00  \x00\x00\x01\x00 \x00\xa8\x10\x00\x00\x16\x00\x00\x00(\x00\x00\x00 \x00\x00\x00@\x00\x00\x00\x01\x00 \x00\x00\x00\x00\x00\x00\x10\x00\x00\x13\x0b\x00\x00\x13\x0b\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xffe\x00`\xffg\x00\xbf\xffe\x00\xfe\xfff\x00\xff\xfff\x00\xff\xfff\x01\xff\xfff\x00\xff\xfff\x00\xff\xfff\x00\xff\xfff\x00\xff\xfff\x00\xff\xfff\x00\xff\xfff\x00\xff\xfff\x00\xff\xfff\x01\xfe\xfff\x01\xff\xfff\x01\xff\xffe\x00\xff\xfff\x00\xff\xfff\x01\xfe\xffg\x00\xfe\xffj\x01\xff\xffk\x00\xff\xffl\x01\xee\xffo\x00\xbf\xffq\x00_\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff`\x00\x10\xfff\x00\xcf\xffe\x00\xfe\xfff\x00\xff\xfff\x00\xff\xffe\x00\xfe\xfff\x00\xff\xfff\x00\xff\xfff\x00\xff\xfff\x00\xff\xfff\x01\xfe\xffe\x01\xfe\xfff\x01\xff\xffe\x00\xff\xfff\x01\xfe\xfff\x01\xff\xfff\x00\xff\xfff\x00\xff\xfff\x01\xff\xfff\x00\xff\xffg\x01\xff\xffh\x00\xff\xffi\x00\xff\xffk\x00\xff\xffl\x00\xff\xffn\x00\xff\xffp\x00\xff\xffq\x00\xfe\xfft\x00\xbf\xffp\x00\x10\x00\x00\x00\x00\x00\x00\x00\x00\xffe\x01\xbf\xffe\x01\xfe\xfff\x00\xff\xfff\x00\xff\xfff\x01\xff\xfff\x00\xff\xfff\x00\xff\xfff\x00\xff\xfff\x00\xff\xfff\x00\xff\xfff\x00\xff\xfff\x00\xff\xfff\x00\xff\xffg\x01\xff\xfff\x00\xff\xfff\x01\xfe\xfff\x00\xff\xfff\x00\xff\xfff\x00\xff\xffg\x00\xff\xffh\x00\xfe\xffj\x00\xff\xffl\x00\xff\xffl\x01\xfe\xffn\x00\xff\xffp\x00\xff\xffr\x00\xff\xffs\x00\xff\xffu\x00\xff\xffw\x00\xcf\x00\x00\x00\x00\xfff\x00_\xfff\x00\xff\xfff\x00\xff\xfff\x01\xfe\xfff\x00\xff\xfff\x00\xff\xfff\x01\xff\xfff\x00\xff\xffe\x00\xfe\xfff\x01\xff\xfff\x01\xfe\xffe\x00\xfe\xfff\x00\xff\xffe\x01\xfe\xffe\x00\xfe\xfff\x01\xfe\xffe\x01\xfe\xfff\x00\xff\xfff\x01\xff\xffg\x00\xff\xffi\x00\xff\xffj\x00\xff\xffl\x00\xff\xffn\x00\xff\xffo\x00\xff\xffp\x00\xff\xffq\x01\xfe\xfft\x00\xff\xffu\x00\xff\xffv\x00\xff\xffx\x01\xff\xffy\x00_\xffg\x00\xbf\xffe\x00\xff\xfff\x01\xff\xfff\x00\xff\xfff\x00\xff\xfff\x00\xff\xfff\x00\xff\xfff\x00\xff\xffe\x00\xfe\xffe\x00\xfe\xfff\x00\xff\xfff\x00\xff\xfff\x01\xff\xfff\x00\xff\xfff\x00\xff\xfff\x00\xff\xfff\x01\xff\xffg\x01\xff\xffg\x00\xff\xffi\x00\xff\xffk\x00\xff\xffl\x00\xff\xffn\x01\xff\xffo\x01\xfe\xffp\x00\xfe\xffr\x01\xff\xffs\x00\xff\xffu\x00\xfe\xffv\x00\xff\xffx\x00\xff\xffy\x00\xfe\xff{\x00\xbf\xfff\x01\xee\xfff\x01\xff\xfff\x00\xff\xffe\x00\xfe\xfff\x01\xff\xff\x8d@\xff\xff\x9f`\xff\xff\x8c@\xff\xfff\x00\xff\xffe\x00\xfe\xffe\x01\xfe\xfff\x01\xff\xfff\x00\xff\xffe\x00\xfe\xfff\x00\xff\xffe\x00\xfe\xfff\x01\xfe\xffh\x00\xff\xffi\x00\xff\xffk\x00\xff\xffl\x01\xfe\xffm\x00\xfe\xffo\x00\xff\xffq\x01\xfe\xffs\x00\xff\xffs\x01\xfe\xffu\x00\xfe\xffv\x00\xff\xffy\x00\xff\xffz\x00\xff\xff{\x01\xfe\xff}\x01\xff\xfff\x00\xff\xfff\x01\xfe\xffe\x00\xff\xfff\x00\xff\xffe\x00\xfe\xff\xa0`\xff\xff\xf5\xef\xff\xff\xff\xff\xff\xff\xd8\xbf\xff\xffy \xfe\xfff\x00\xff\xfff\x00\xff\xfff\x01\xff\xffe\x00\xfe\xfff\x01\xff\xff\xc5\xa0\xff\xffh\x00\xff\xffj\x01\xff\xffk\x00\xff\xffl\x01\xfe\xff\xc9\xa0\xff\xff\x94@\xff\xffq\x00\xff\xffs\x00\xff\xfft\x00\xff\xffv\x01\xff\xffw\x00\xff\xffx\x00\xfe\xffz\x00\xff\xff{\x00\xff\xff}\x01\xfe\xff\x7f\x00\xff\xffe\x00\xfe\xfff\x01\xff\xfff\x00\xff\xfff\x00\xff\xfff\x00\xff\xfff\x00\xff\xff\x820\xff\xff\xf5\xef\xff\xff\xff\xff\xff\xff\xec\xdf\xff\xfff\x00\xff\xfff\x01\xfe\xffe\x00\xfe\xfff\x00\xff\xff\xa9p\xff\xff\xff\xff\xff\xffs\x10\xff\xffl\x00\xff\xffm\x00\xff\xffn\x00\xff\xff\xf6\xef\xff\xff\xff\xff\xff\xff\xc2\x90\xff\xff}\x11\xff\xffu\x01\xfe\xffx\x00\xff\xffy\x00\xff\xffz\x00\xfe\xff|\x01\xff\xff}\x01\xfe\xff\x80\x01\xff\xff\x80\x00\xff\xfff\x00\xff\xfff\x00\xfe\xfff\x00\xff\xfff\x00\xff\xfff\x00\xff\xfff\x00\xff\xfff\x00\xff\xff\x9f`\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xb3\x80\xfe\xffe\x01\xfe\xfff\x00\xff\xffz!\xff\xff\xf5\xef\xff\xff\xff\xff\xff\xff~ \xff\xff\xa4`\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff|\x00\xfe\xff~\x01\xff\xff\x80\x00\xff\xff\x80\x00\xfe\xff\x82\x00\xfe\xffe\x00\xfe\xfff\x00\xff\xfff\x01\xff\xfff\x01\xff\xffe\x00\xff\xfff\x01\xff\xfff\x01\xfe\xfff\x00\xff\xff\xc5\xa0\xff\xff\xff\xff\xff\xff\xec\xdf\xff\xffy \xff\xffg\x00\xff\xff\xd9\xbf\xff\xff\xff\xff\xff\xff\xda\xbf\xff\xffm\x01\xff\xff\xa5`\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x97@\xff\xff\xd5\xaf\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff~\x00\xff\xff\x80\x01\xff\xff\x80\x01\xfe\xff\x82\x00\xfe\xff\x84\x01\xff\xfff\x00\xff\xfff\x00\xff\xfff\x00\xff\xfff\x00\xff\xfff\x00\xff\xfff\x00\xff\xfff\x01\xff\xfff\x01\xfe\xffx!\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xff\xa1`\xff\xff\xacp\xfe\xff\xff\xff\xff\xff\xf6\xef\xff\xff\x80 \xfe\xffo\x00\xfe\xff\xa6`\xff\xff\xff\xff\xff\xff\xdc\xbf\xff\xffu\x00\xff\xffv\x01\xfe\xffx\x00\xff\xffz\x00\xff\xff\x8b \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x80\x00\xff\xff\x81\x01\xfe\xff\x82\x01\xfe\xff\x84\x00\xff\xff\x85\x00\xff\xfff\x00\xff\xfff\x00\xff\xffe\x00\xfe\xfff\x01\xff\xffg\x01\xff\xfff\x00\xff\xffe\x01\xfe\xfff\x00\xff\xfff\x00\xff\xff\xc6\xa0\xff\xff\xff\xff\xff\xff\xda\xbf\xff\xff\xec\xdf\xff\xff\xff\xff\xff\xff\xaep\xff\xffp\x00\xff\xffq\x00\xff\xff\xa7`\xff\xff\xff\xff\xff\xff\xdd\xbf\xff\xffw\x00\xfe\xffy\x00\xff\xffy\x01\xfe\xff|\x00\xff\xff\x8d!\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xff\x82\x00\xff\xff\x83\x00\xff\xff\x85\x00\xff\xff\x86\x00\xff\xff\x88\x00\xff\xfff\x01\xfe\xfff\x00\xff\xfff\x00\xff\xfff\x00\xff\xfff\x00\xff\xfff\x01\xff\xffe\x00\xfe\xfff\x00\xff\xffg\x00\xff\xff\x8e@\xfe\xff\xff\xff\xff\xff\xf6\xef\xff\xff\x7f \xff\xff\xc0\x90\xff\xffp\x00\xff\xffq\x01\xfe\xffs\x00\xff\xff\xa8`\xff\xff\xff\xff\xff\xff\xde\xbf\xff\xffy\x00\xff\xffz\x00\xfe\xff|\x01\xff\xff~\x01\xff\xff\x8f \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x83\x00\xff\xff\x85\x00\xff\xff\x87\x01\xff\xff\x88\x01\xff\xff\x89\x00\xff\xfff\x01\xfe\xfff\x00\xff\xfff\x00\xff\xfff\x00\xff\xfff\x01\xff\xfff\x00\xff\xfff\x00\xff\xfff\x00\xfe\xffh\x01\xfe\xffj\x00\xff\xff\xf6\xef\xff\xff\xff\xff\xff\xff\x891\xfe\xffp\x01\xff\xffq\x00\xff\xffs\x00\xff\xfft\x01\xfe\xff\xa9`\xff\xff\xff\xff\xff\xff\xde\xbf\xff\xff{\x01\xff\xff}\x01\xff\xff}\x00\xfe\xff\x7f\x00\xff\xff\x91!\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xff\x85\x01\xff\xff\x87\x01\xff\xff\x88\x01\xfe\xff\x8a\x00\xff\xff\x8a\x01\xfe\xfff\x01\xff\xfff\x01\xfe\xfff\x01\xfe\xfff\x00\xff\xfff\x01\xff\xffp\x10\xff\xffz!\xfe\xff{ \xfe\xff} \xff\xff~ \xff\xff\xe4\xcf\xff\xff\xff\xff\xff\xff\x9dP\xff\xffq\x01\xfe\xffs\x00\xff\xffu\x00\xff\xffv\x00\xff\xff\xaba\xfe\xff\xff\xff\xff\xff\xde\xbf\xff\xff}\x00\xff\xff~\x00\xff\xff\x7f\x00\xff\xff\x80\x01\xfe\xff\x92 \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x87\x00\xff\xff\x89\x01\xff\xff\x89\x00\xfe\xff\x8b\x00\xfe\xff\x8d\x01\xfe\xfff\x00\xff\xfff\x01\xff\xfff\x01\xfe\xfff\x00\xff\xfff\x01\xfe\xff\xbd\x90\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xee\xdf\xff\xff\xad`\xfe\xff\xff\xff\xff\xff\xdf\xbf\xff\xff~\x01\xff\xff\x80\x01\xfe\xff\x81\x00\xff\xff\x83\x00\xff\xff\x94 \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x89\x01\xff\xff\x8a\x01\xff\xff\x8c\x01\xff\xff\x8e\x01\xff\xff\x8f\x00\xff\xfff\x00\xff\xfff\x01\xff\xfff\x01\xfe\xfff\x00\xff\xffh\x00\xff\xff| \xff\xff\xda\xbf\xff\xff\xec\xdf\xff\xff\xed\xdf\xff\xff\xed\xdf\xff\xff\xf6\xef\xff\xff\xff\xff\xff\xff\xf7\xef\xff\xff\xee\xdf\xff\xff\xee\xdf\xff\xff\xef\xdf\xff\xff\xce\x9f\xff\xff\xad`\xff\xff\xff\xff\xff\xff\xdf\xbf\xff\xff\x80\x01\xff\xff\x81\x00\xff\xff\x83\x00\xff\xff\x84\x00\xfe\xff\x95 \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x8b\x01\xff\xff\x8c\x00\xff\xff\x8e\x01\xff\xff\x8f\x00\xff\xff\x91\x00\xfe\xfff\x01\xff\xfff\x00\xff\xffg\x00\xff\xffi\x00\xff\xffi\x00\xff\xffk\x00\xff\xffm\x01\xff\xffn\x00\xfe\xffp\x00\xff\xffq\x00\xff\xff\xb9\x80\xff\xff\xff\xff\xff\xff\xcb\x9f\xff\xffw\x00\xff\xffy\x01\xff\xffz\x00\xfe\xff{\x00\xff\xff\xae`\xff\xff\xff\xff\xff\xff\xe0\xbf\xff\xff\x82\x00\xff\xff\x83\x01\xfe\xff\x85\x00\xff\xff\x86\x01\xfe\xff\x97!\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xff\x8c\x00\xfe\xff\x8e\x00\xff\xff\x8f\x00\xff\xff\x91\x00\xff\xff\x93\x01\xfe\xfff\x00\xff\xffg\x00\xff\xffi\x01\xff\xffj\x00\xff\xffl\x00\xff\xffm\x00\xff\xffo\x00\xff\xffp\x00\xff\xffr\x00\xff\xffs\x00\xff\xff\xb9\x80\xff\xff\xff\xff\xff\xff\xcc\x9f\xff\xffy\x00\xff\xff{\x01\xff\xff|\x00\xff\xff~\x00\xff\xff\xaf`\xff\xff\xff\xff\xff\xff\xe0\xbf\xff\xff\x84\x00\xff\xff\x85\x00\xff\xff\x87\x00\xff\xff\x87\x01\xfe\xff\x98 \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x8f\x00\xff\xff\x90\x00\xfe\xff\x91\x01\xff\xff\x93\x01\xfe\xff\x94\x00\xff\xffg\x00\xff\xffi\x01\xff\xffj\x01\xfe\xffl\x01\xfe\xffm\x00\xff\xff\x9bP\xff\xff\xafp\xfe\xffz\x11\xfe\xfft\x01\xff\xffu\x00\xff\xff\xba\x80\xff\xff\xff\xff\xff\xff\xcd\x9f\xff\xff{\x00\xff\xff|\x01\xfe\xff~\x00\xff\xff\x80\x00\xff\xff\xb0a\xff\xff\xff\xff\xff\xff\xe0\xbf\xff\xff\x85\x00\xff\xff\x87\x00\xfe\xff\x88\x00\xff\xff\x8a\x01\xfe\xff\x9a \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x90\x00\xff\xff\x92\x00\xff\xff\x93\x00\xff\xff\x94\x00\xff\xff\x97\x00\xfe\xffi\x00\xff\xffj\x00\xff\xffl\x00\xff\xffm\x00\xff\xffo\x00\xff\xff\x94@\xff\xff\xff\xff\xff\xff\xee\xdf\xff\xff\x87 \xff\xffw\x01\xff\xff\xbc\x80\xff\xff\xff\xff\xff\xff\xce\x9f\xff\xff|\x00\xff\xff~\x00\xff\xff\x80\x00\xff\xff\x81\x00\xff\xff\xb1`\xff\xff\xff\xff\xff\xff\xe0\xbf\xff\xff\x88\x01\xff\xff\x89\x00\xff\xff\x8a\x00\xff\xff\x8c\x01\xff\xff\x9b \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x92\x01\xff\xff\x93\x01\xff\xff\x95\x00\xff\xff\x97\x01\xfe\xff\x98\x00\xff\xffj\x00\xfe\xffm\x01\xff\xffn\x01\xff\xffp\x01\xff\xffq\x00\xff\xffr\x00\xff\xff\xdc\xbf\xff\xff\xff\xff\xff\xff\xc3\x90\xff\xffx\x01\xfe\xff\xbc\x80\xff\xff\xff\xff\xff\xff\xcf\x9f\xff\xff~\x00\xff\xff\x80\x01\xff\xff\x81\x00\xff\xff\x83\x01\xfe\xff\xb2`\xff\xff\xff\xff\xff\xff\xe1\xbf\xff\xff\x89\x01\xff\xff\x8a\x00\xff\xff\x8c\x00\xff\xff\x8e\x00\xff\xff\x9d \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x94\x01\xff\xff\x95\x00\xff\xff\x97\x01\xfe\xff\x98\x00\xff\xff\x9a\x00\xff\xffl\x01\xfe\xffn\x01\xfe\xffp\x00\xff\xffq\x00\xff\xffs\x00\xff\xfft\x00\xfe\xff\xa9`\xff\xff\xff\xff\xff\xff\xf7\xef\xff\xff\xde\xbf\xff\xff\xef\xdf\xff\xff\xff\xff\xff\xff\xf7\xef\xff\xff\xdf\xbf\xff\xff\xdf\xbf\xff\xff\xdf\xbf\xff\xff\xb3`\xff\xff\xb3a\xff\xff\xff\xff\xff\xff\xf7\xef\xff\xff\xe1\xbf\xff\xff\xe3\xbf\xff\xff\xe3\xbf\xff\xff\xe3\xbf\xff\xff\xe3\xbf\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x95\x00\xff\xff\x97\x00\xfe\xff\x98\x00\xff\xff\x9a\x00\xff\xff\x9b\x00\xff\xffn\x00\xff\xffp\x00\xff\xffq\x00\xff\xffs\x00\xfe\xffu\x00\xff\xffv\x00\xff\xff\x88 \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xb4`\xff\xff\xb4`\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x98\x00\xfe\xff\x99\x01\xff\xff\x9a\x00\xff\xff\x9c\x00\xff\xff\x9e\x01\xff\xffq\x00\xff\xffq\x01\xfe\xffs\x00\xff\xffu\x00\xff\xffv\x00\xff\xffx\x00\xff\xffy\x01\xfe\xff\xd6\xaf\xff\xff\xff\xff\xff\xff\xc7\x90\xff\xff\xa0@\xfe\xff\xa1@\xff\xff\xa1@\xff\xff\xa3@\xfe\xff\xa4@\xff\xff\xa5@\xff\xff\x89\x01\xff\xff\x91\x11\xff\xff\xa9@\xff\xff\xaa@\xff\xff\xab@\xff\xff\xac@\xff\xff\xad@\xff\xff\xae@\xff\xff\xaf@\xff\xff\xb0@\xff\xff\xb2@\xff\xff\x99\x00\xff\xff\x9b\x00\xfe\xff\x9c\x01\xff\xff\x9e\x00\xfe\xff\x9f\x00\xff\xffr\x00\xff\xfft\x01\xff\xffu\x00\xff\xffv\x00\xff\xffx\x01\xfe\xffy\x00\xfe\xff{\x01\xff\xff\xad`\xff\xff\xff\xff\xff\xff\xe7\xcf\xff\xff\x81\x00\xff\xff\x82\x00\xff\xff\x85\x01\xff\xff\x86\x01\xff\xff\x87\x00\xfe\xff\x89\x00\xff\xff\x8a\x00\xfe\xff\x8c\x00\xff\xff\x8d\x00\xff\xff\x8f\x00\xff\xff\x90\x00\xff\xff\x92\x01\xfe\xff\x93\x00\xff\xff\x96\x01\xfe\xff\x96\x00\xff\xff\x98\x00\xff\xff\x9a\x00\xfe\xff\x9b\x00\xff\xff\x9d\x01\xff\xff\x9e\x00\xfe\xff\x9f\x00\xff\xff\xa1\x00\xff\xfft\x00\xff\xffu\x01\xff\xffw\x00\xff\xffx\x00\xff\xffz\x01\xff\xff{\x00\xff\xff}\x00\xff\xff\x7f\x00\xff\xff\xb7p\xff\xff\xf7\xef\xff\xff\x93 \xfe\xff\x84\x00\xff\xff\x85\x00\xff\xff\x87\x00\xff\xff\x88\x00\xfe\xff\x8b\x00\xff\xff\x8c\x01\xff\xff\x8d\x00\xff\xff\x8f\x00\xff\xff\x91\x01\xff\xff\x92\x01\xff\xff\x94\x00\xff\xff\x95\x00\xff\xff\x97\x01\xfe\xff\x98\x01\xfe\xff\x9a\x00\xff\xff\x9b\x01\xff\xff\x9d\x01\xff\xff\x9e\x00\xff\xff\xa0\x00\xfe\xff\xa1\x00\xff\xff\xa3\x00\xef\xffw\x01\xbf\xffw\x00\xff\xffy\x00\xff\xffz\x01\xfe\xff{\x00\xff\xff}\x00\xff\xff\x7f\x00\xff\xff\x80\x00\xff\xff\x82\x01\xff\xff\x84\x00\xff\xff\x85\x00\xff\xff\x86\x00\xfe\xff\x87\x01\xfe\xff\x89\x00\xff\xff\x8b\x01\xfe\xff\x8c\x00\xff\xff\x8e\x01\xfe\xff\x8f\x00\xff\xff\x91\x01\xfe\xff\x93\x00\xff\xff\x95\x01\xfe\xff\x95\x00\xff\xff\x97\x00\xff\xff\x98\x00\xff\xff\x9a\x00\xff\xff\x9c\x01\xff\xff\x9d\x00\xff\xff\x9f\x01\xff\xff\xa0\x00\xff\xff\xa2\x01\xff\xff\xa3\x01\xff\xff\xa4\x00\xbf\xffx\x00`\xffy\x01\xff\xffz\x00\xff\xff|\x01\xff\xff~\x01\xff\xff\x80\x00\xff\xff\x80\x00\xff\xff\x82\x01\xff\xff\x83\x00\xff\xff\x85\x00\xfe\xff\x86\x01\xff\xff\x88\x00\xff\xff\x8a\x00\xff\xff\x8b\x01\xff\xff\x8d\x00\xff\xff\x8e\x00\xff\xff\x90\x00\xff\xff\x91\x00\xff\xff\x93\x00\xff\xff\x95\x00\xff\xff\x96\x01\xfe\xff\x97\x00\xff\xff\x99\x00\xff\xff\x9b\x00\xfe\xff\x9c\x01\xfe\xff\x9d\x01\xff\xff\x9f\x00\xff\xff\xa0\x00\xff\xff\xa2\x01\xff\xff\xa3\x00\xff\xff\xa5\x00\xff\xff\xa6\x00_\x00\x00\x00\x00\xffz\x01\xcf\xff|\x00\xff\xff~\x01\xfe\xff\x80\x01\xff\xff\x81\x00\xff\xff\x82\x01\xff\xff\x83\x01\xfe\xff\x86\x01\xff\xff\x86\x00\xfe\xff\x88\x01\xfe\xff\x8a\x01\xfe\xff\x8b\x01\xfe\xff\x8d\x00\xff\xff\x8e\x00\xfe\xff\x90\x00\xfe\xff\x91\x00\xff\xff\x93\x00\xfe\xff\x95\x00\xff\xff\x97\x00\xfe\xff\x97\x00\xff\xff\x99\x00\xff\xff\x9a\x00\xff\xff\x9c\x00\xff\xff\x9e\x01\xfe\xff\x9f\x00\xff\xff\xa1\x00\xff\xff\xa2\x01\xff\xff\xa4\x01\xfe\xff\xa5\x00\xff\xff\xa7\x00\xbf\x00\x00\x00\x00\x00\x00\x00\x00\xff\x80\x00\x10\xff}\x00\xbf\xff\x80\x01\xfe\xff\x81\x00\xff\xff\x83\x00\xff\xff\x84\x01\xfe\xff\x85\x00\xff\xff\x87\x01\xff\xff\x89\x01\xff\xff\x8a\x00\xff\xff\x8b\x00\xff\xff\x8d\x01\xfe\xff\x8e\x00\xff\xff\x90\x00\xff\xff\x92\x01\xfe\xff\x94\x00\xfe\xff\x94\x00\xff\xff\x96\x00\xff\xff\x98\x00\xff\xff\x99\x00\xff\xff\x9b\x00\xff\xff\x9c\x00\xff\xff\x9d\x00\xff\xff\x9f\x01\xff\xff\xa1\x01\xff\xff\xa2\x01\xff\xff\xa3\x00\xff\xff\xa5\x00\xff\xff\xa7\x00\xcf\xff\x9f\x00\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\x81\x00_\xff\x83\x00\xbf\xff\x84\x00\xef\xff\x85\x00\xfe\xff\x87\x00\xff\xff\x89\x01\xfe\xff\x8a\x00\xff\xff\x8c\x00\xff\xff\x8d\x00\xff\xff\x90\x01\xfe\xff\x90\x00\xff\xff\x92\x01\xff\xff\x94\x01\xff\xff\x95\x00\xff\xff\x97\x00\xff\xff\x98\x00\xff\xff\x9a\x01\xfe\xff\x9b\x00\xff\xff\x9d\x01\xfe\xff\x9e\x00\xff\xff\x9f\x00\xff\xff\xa1\x00\xff\xff\xa3\x01\xff\xff\xa4\x00\xff\xff\xa5\x00\xbf\xff\xa6\x00_\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xe0\x00\x00\x07\x80\x00\x00\x01\x80\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80\x00\x00\x01\x80\x00\x00\x01\xe0\x00\x00\x07'

这里打印了两行是Response对象的两个属性,一个是text【str类型】,另外一个是content【字节】

import requests


headers = {
    "User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.45 Safari/537.36"
}
reponse = requests.get("https://static.zhihu.com/heifetz/favicon.ico",headers=headers)
with open("favicon.ico","wb") as f:
    f.write(reponse.content)

结果
 

 POST请求

前面我们了解了最基本的 GET 请求另外一种比较常见的请求方式是 POST 使用 requests实现 POST 请求同样非常简单,示例如下:

import requests

date = {
    "name":"germey",
    "age":22
}

response = requests.post(url="http://192.168.1.104/post",data=date)
print(response.text)

结果:
{
  "args": {}, 
  "data": "", 
  "files": {}, 
  "form": {
    "age": "22", 
    "name": "germey"
  }, 
  "headers": {
    "Accept": "*/*", 
    "Accept-Encoding": "gzip, deflate", 
    "Connection": "keep-alive", 
    "Content-Length": "18", 
    "Content-Type": "application/x-www-form-urlencoded", 
    "Host": "192.168.1.104", 
    "User-Agent": "python-requests/2.25.1"
  }, 
  "json": null, 
  "origin": "192.168.1.101", 
  "url": "http://192.168.1.104/post"
}

常用的响应

import requests

response = requests.post(url="http://192.168.1.104/post",data=date)
print(type(response.status_code),response.status_code)
print(type(response.headers),response.headers)
print(type(response.cookies),response.cookies)
print(type(response.url),response.url)
print(type(response.history),response.history)


结果:
<class 'int'> 200
<class 'requests.structures.CaseInsensitiveDict'> {'Server': 'gunicorn/19.9.0', 'Date': 'Tue, 30 Nov 2021 14:26:55 GMT', 'Connection': 'keep-alive', 'Content-Type': 'application/json', 'Content-Length': '468', 'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Credentials': 'true'}
<class 'requests.cookies.RequestsCookieJar'> <RequestsCookieJar[]>
<class 'str'> http://192.168.1.104/post
<class 'list'> []

这里分别打印输出 status_code 属性得到状态码,输出 headers 属性得到响应头,输出 cookies 属性得到 Cookies ,输出 url 属性得到URL ,输出 history 属性得到请求历史

状态码常用来判断请求是否成功,而 requests 还提供了一个 置的状态码查询对象 requests.codes, 示例如下:

import requests

response = requests.post(url="http://192.168.1.104/post",data=date)
exit() if not response.status_code == requests.codes.ok else print("Request Successfully")

结果:
Request Successfully

常用的返回码和响应的查询条件

 

 

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/Smart_look/article/details/121643058

智能推荐

ASA与PIX的区别-程序员宅基地

文章浏览阅读68次。很多年来,Cisco PIX一直都是Cisco确定的防火墙。但是在2005年5月,Cisco推出了一个新的产品——适应性安全产品(ASA,Adaptive Security Appliance)。不过,PIX还依旧可用。我已听到很多人在多次询问这两个产品线之间的差异到底是什么。让我们来看一看。Cisco PIX是什么?Cisco PIX是一种专用的硬件防火墙。所有版本..._pix asa区别

TensorFlow conv2d原理及实践-程序员宅基地

文章浏览阅读235次。tf.nn.conv2d(input, filter, strides, padding, use_cudnn_on_gpu=None, data_format=None, name=None)官方教程说明:给定四维的input和filtertensor,计算一个二维卷积Args:input: ATensor. type必须是以下几种类型之一:half,float32,..._conv2d原理 l

linux服务器初始化(防火墙、内核优化、时间同步、打开文件数)-程序员宅基地

文章浏览阅读83次。#!/bin/bashread -p 'enter the network segment for visiting the server:' ips# 关闭firewalld和selinuxsystemctl stop firewalldsystemctl disable firewalldsed -i 's\SELINUX=enforcing\SEL..._服务器是不是没做打开文件数优化

solr7集群 springboot_springboot整合solr-程序员宅基地

文章浏览阅读116次。一、本文将solr安装在linux上。首先先安装好jdk和tomcat。配置环境:jdk8,tomcat8.5,solr7.2.1.。二、复制Solr文件夹中的一些文件到apache-tomcat下:1)将 solr 压缩包中 solr\server\solr-webapp\文件夹下有个webapp文件夹,将之复制到tomcat\webapps\目录下,文件夹名改成solr(任意) ;cp -R ..._springboot solr7

在java中已经规定数据类型是长整形为什么数字后面还要加一个"l"啊?前面不是有long吗?_java数字后面加l是什么意思-程序员宅基地

文章浏览阅读2.6k次,点赞2次,收藏5次。说到这就不得不谈java的内存体制,建议你好好研究下这个。example:long l1 = 10000000000L;实际上内存中l1只是一个long类型的变量,它存在于向stack(栈)中,数值并不在其中存放,它指向heap(堆)中另一块真正存放数值的内存,加L的目的就是为了让heap中也创建一块long类型所需要的内存,用来来放数值。所以说=前后两者其实是在不同的两块内存,只不过有..._java数字后面加l是什么意思

最完整的RocketMq部署程序,包括rocketmq-console部署和测试程序的介绍_rocketmq-console-test-程序员宅基地

文章浏览阅读4k次。文章目录1.RocketMq部署准备工作RocketMq程序的获取启动NameServer启动Broker查看log日志2.运维工具部署获取程序参数配置运行程序3.实际测试代码获取运行4.开始学习~1.RocketMq部署本文详细介绍了安装rocketMq 前后的方法和一些注意事项 ,设备为centos7,话不多说,begin。准备工作RocketMq程序的获取首先需要获取rocketM..._rocketmq-console-test

随便推点

20 个最重要的 DevOps 面试题-程序员宅基地

文章浏览阅读2.5k次。点击下方公众号「关注」和「星标」回复“1024”获取独家整理的学习资料!DevOps 代表开发和运营。这是一种新的软件开发形式,彻底改变了软件产品的开发和分发方式。DevOps方法论着眼于..._devops面试题

根据时间生成分配批次号-程序员宅基地

文章浏览阅读1.3k次。1 /** 2 * 根据当前时间生成分配批次号 3 * 4 * @return 5 */ 6 private String createBatchNo() { 7 // 批次号第一部分:时间 8 DateFormat dateFormat = new SimpleD..._java根据时间生成批注号

Nodejs之事件驱动+非阻塞io模型_了基于事件驱动和非阻塞 i/o 的模型-程序员宅基地

文章浏览阅读6.5k次,点赞2次,收藏8次。1什么是i/o? io input、output 输入输出,电脑的输入输出,例如音频录音表示声音输入、听音乐是声音的输出 网络上的传输全部是在传字符串,i/o在服务器上可以理解为读写操作。2什么是并发? 一个时间段中有几个程序都处于已启动运行到运行完毕之间。3异步i/o与事件驱动3.1什么是进程?进程是为运行当中的应用程序提供运行环境的一个运行当中的应用程序就会有一个进程与之相对应3_了基于事件驱动和非阻塞 i/o 的模型

tv端h5_H5在三端开发遇到的问题(TV/PC/MOBILE)-程序员宅基地

文章浏览阅读1.1k次。项目简介公司最近开发会员体系项目,前端利用H5技术嵌入三端开发页面,TV端原生技术是C++,PC端原生技术是JAVA。传值问题Javascript与安卓/IOS进行交互。原生把方法暴露给window。前端只需要下window对象调用方法,进行传值即可。notice:function(token,uuid){var pattern = new RegExp('iPhone|iPad', 'ig');..._电视端app可以用h5写吗

python下mqtt服务器的搭建_转 【MQTT】在Windows下搭建MQTT服务器-程序员宅基地

文章浏览阅读498次。MQTT简介MQ 遥测传输 (MQTT) 是轻量级基于代理的发布/订阅的消息传输协议,设计思想是开放、简单、轻量、易于实现。这些特点使它适用于受限环境。该协议的特点有:使用发布/订阅消息模式,提供一对多的消息发布,解除应用程序耦合。对负载内容屏蔽的消息传输。使用 TCP/IP 提供网络连接。小型传输,开销很小(固定长度的头部是 2 字节),协议交换最小化,以降低网络流量。使用 Last Will ..._python window环境搭建 mqtt服务端

win10安装python详细过程_win10怎么正确安装python-程序员宅基地

文章浏览阅读10w+次,点赞53次,收藏173次。关于python的安装一切语言皆为工具接下来咱们就开始吧一切语言皆为工具既然你决定安装它,那就已经告知自己要掌握这门工具,但是有一定你一定要铭记于心那就是:python 是个工具时刻想着如何用它解决你的问题【哪怕是一个简单的想法】接下来咱们就开始吧下载安装软件包登录官网 :https://www.python.org/downloads/release/python-373..._win10怎么正确安装python

推荐文章

热门文章

相关标签