爬虫:使用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

智能推荐

用批处理编译*.sln工程-程序员宅基地

文章浏览阅读72次。首先感谢DUDU百忙之中帮我恢复了BLOG的密码.大家还是把口令设置强一点.免得麻烦DUDU了。最近半年一直到开发公司的MES开发平台工具,自己要维护10多个工程,其中一些公共库更新的也比较频繁,每日的Build相当的消耗时间,因为Release到不同的目录,存在一些DLL版本的问题;为了解决这个问题,首先想到了 FinalBuilder ,但..._windows bat编译2017 sln文件

JSON和XML的区别_jason 文件与 xml 的区别-程序员宅基地

文章浏览阅读4.9k次,点赞2次,收藏32次。JSON和XML之间的区别是什么?下面本篇文章就来给大家比较一下JSON和XML,介绍JSON和XML之间的区别,希望对大家有所帮助。JSON(JavaScript Object Notation)是一种轻量级的数据交换格式,它完全独立于语言。它基于JavaScript编程语言,易于理解和生成。示例:{"Student":[ { "Name":"Vivek", "age":"20" }, { "Name":"Suraj", "age":"19" }, { "N_jason 文件与 xml 的区别

Rust macro开发新手入门_rust c marco-程序员宅基地

文章浏览阅读853次。Rust语言最强大的一个特点就是可以创建和利用宏/Macro。不过创建Rust宏看起来挺复杂,常常令刚接触Rust的开发者心生畏惧。这片文章的目的就是帮助你理解Rust Macro的基本运作原理,学习如何创建自己的Rust宏。相关链接:在线学编程1、什么是Rust的宏/Macro?如果你尝试过Rust,应该已经用过Rust的宏了:println!。这个宏可以在终端输出一行文本,并且支持..._rust c marco

error: invalid application of ‘sizeof’ to incomplete type ‘QStaticAssertFailure_invalid application of 'sizeof' to incomplete type-程序员宅基地

文章浏览阅读1k次。error: invalid application of ‘sizeof’ to incomplete type ‘QStaticAssertFailure’C:\Qt\Qt5.3.2\5.3\mingw482_32\include\QtCore\qglobal.h:698: error: invalid application of ‘sizeof’ to incomplete type ‘QS_invalid application of 'sizeof' to incomplete type 'qstaticassertfailure

idea - idea修改jdk版本_idea取消jdk下载-程序员宅基地

文章浏览阅读773次。依次序: file--setting file--Project Structure file--Project Structure 参考https://blog.csdn.net/hanjun0612/article/details/72845918_idea取消jdk下载

RHCE练习题目【已完结】-程序员宅基地

文章浏览阅读2.9k次,点赞9次,收藏44次。设置tab键,方便编写ymal文件。检查剧本是否有语法错误,执行剧本。在workstation上安装。编写安装相关软件包的剧本。

随便推点

汉字转换_tt99911.cm-程序员宅基地

文章浏览阅读2.6w次。中文转Unicodefunction unicode(str) { var value = ''; for (var i = 0; i < str.length; i++) { value += '\\u' + left_zero_4(parseInt(str.charCodeAt(i)).toString(16)); } return value;}function left_zero_4(str) { if (str != nul_tt99911.cm

【AD】安装AD18教程-程序员宅基地

文章浏览阅读2.8k次,点赞3次,收藏14次。百度云链接:https://pan.baidu.com/s/1WoSISGOWC_1E2Bm2GcLfLQ提取码:fyuk1、打开安装包2、选择语言包,选择中文包,点击接受协议内容3、一般选择安装“PCB Design”、“Importers\Exporters”两项即可4、选择自己的安装路径,注意要全英路径5、正在安装6、安装完成,这个勾先去...

mysql优化-程序员宅基地

文章浏览阅读133次。在sql查询中为了提高查询效率,我们常常会采取一些措施对查询语句进行sql优化:①应尽量避免全表扫描,首先应考虑在 where 及 order by 涉及的列上建立索引1.应尽量避免在 where 子句中使用!=或<>操作符,否则将引擎放弃使用索引而进行全表扫描2.应尽量避免在 where 子句中使用 or 来连接条件,否则将导致引擎放弃使用索引而进行全表扫描,如:...

Python《成功破解简单的 动态加载 的爬虫》_爬虫遇到当图片显示时,src动态改变,如何破界-程序员宅基地

文章浏览阅读535次。今天我们来爬取一个漫画网站这里由于漫画数量过于庞大,于是我就简单地爬取曾经小时候看过的漫画吧。比如下面的五个漫画:先来分析分析,拿《火影忍者》举例:点击进去后可以看到所有的章节罗列。嗯,这个没啥说的了,就是搜索出所有的< a>元素,找出其章节的标签,并且得到具体章节的链接,这个简单。继续点击其中某个章节进去后发现,是存在多个页面的插画,共同组成一个章节,这个总体来说也不难,因为url很有规律,url是递增的,直到共X页面,且每一页只有一张图片,我们只需要跳转到每一页下载一张图就_爬虫遇到当图片显示时,src动态改变,如何破界

Vue子组件与父组件传值方式以及它们之间调用彼此的方法-程序员宅基地

文章浏览阅读245次。1、父组件向子组件传值:子组件通过props获取父组件传来的值//父组件main.vue<template> <div> <child :data="message"></child> </div></template><script>data(){return{message:'你好'}...

python的sklearn分析酒店评分影响因素_python代码实现机器学习对酒店评分-程序员宅基地

文章浏览阅读2k次。酒店的评价不外乎设施,位置便利性,卫生和服务质量几个因素,我从数据超市下载一个数据集,将其中几个评分清洗出来截图如下#多元回归 分析获得客户评价对推荐人数的影响import pandas as pdimport statsmodels.api as smfrom sklearn.linear_model import LinearRegressionfilename = "../../data/各项评分.xls"data = pd.read_excel(filename)print(da_python代码实现机器学习对酒店评分

推荐文章

热门文章

相关标签