2024Python常见面试题python爬虫的requests库详解(1),快点来学吧

print(json.loads(response.text))

print(type(response.json()))

获取二进制数据

import requests

response = requests.get(“https://github.com/favicon.ico”)

print(type(response.text), type(response.content))

print(response.text)

print(response.content)

import requests

response = requests.get(“https://github.com/favicon.ico”)

with open(‘favicon.ico’, ‘wb’) as f:

f.write(response.content)

f.close()

添加headers

import requests

response = requests.get(“https://www.zhihu.com/explore”)

print(response.text)

import requests

headers = {

‘User-Agent’: ‘Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36’

}

response = requests.get(“https://www.zhihu.com/explore”, headers=headers)

print(response.text)

基本POST请求


import requests

data = {‘name’: ‘germey’, ‘age’: ‘22’}

response = requests.post(“http://httpbin.org/post”, data=data)

print(response.text)

import requests

data = {‘name’: ‘germey’, ‘age’: ‘22’}

headers = {

‘User-Agent’: ‘Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36’

}

response = requests.post(“http://httpbin.org/post”, data=data, headers=headers)

print(response.json())

响应

============================================================

reponse属性


import requests

response = requests.get(‘http://www.jianshu.com’)

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)

状态码判断


import requests

response = requests.get(‘http://www.jianshu.com/hello.html’)

exit() if not response.status_code == requests.codes.not_found else print(‘404 Not Found’)

import requests

response = requests.get(‘http://www.jianshu.com’)

exit() if not response.status_code == 200 else print(‘Request Successfully’)

100: (‘continue’,),

101: (‘switching_protocols’,),

102: (‘processing’,),

103: (‘checkpoint’,),

122: (‘uri_too_long’, ‘request_uri_too_long’),

200: (‘ok’, ‘okay’, ‘all_ok’, ‘all_okay’, ‘all_good’, ‘\o/’, ‘✓’),

201: (‘created’,),

202: (‘accepted’,),

203: (‘non_authoritative_info’, ‘non_authoritative_information’),

204: (‘no_content’,),

205: (‘reset_content’, ‘reset’),

206: (‘partial_content’, ‘partial’),

207: (‘multi_status’, ‘multiple_status’, ‘multi_stati’, ‘multiple_stati’),

208: (‘already_reported’,),

226: (‘im_used’,),

Redirection.

300: (‘multiple_choices’,),

301: (‘moved_permanently’, ‘moved’, ‘\o-’),

302: (‘found’,),

303: (‘see_other’, ‘other’),

304: (‘not_modified’,),

305: (‘use_proxy’,),

306: (‘switch_proxy’,),

307: (‘temporary_redirect’, ‘temporary_moved’, ‘temporary’),

308: (‘permanent_redirect’,

‘resume_incomplete’, ‘resume’,), # These 2 to be removed in 3.0

Client Error.

400: (‘bad_request’, ‘bad’),

401: (‘unauthorized’,),

402: (‘payment_required’, ‘payment’),

403: (‘forbidden’,),

404: (‘not_found’, ‘-o-’),

405: (‘method_not_allowed’, ‘not_allowed’),

406: (‘not_acceptable’,),

407: (‘proxy_authentication_required’, ‘proxy_auth’, ‘proxy_authentication’),

408: (‘request_timeout’, ‘timeout’),

409: (‘conflict’,),

410: (‘gone’,),

411: (‘length_required’,),

412: (‘precondition_failed’, ‘precondition’),

413: (‘request_entity_too_large’,),

414: (‘request_uri_too_large’,),

415: (‘unsupported_media_type’, ‘unsupported_media’, ‘media_type’),

416: (‘requested_range_not_satisfiable’, ‘requested_range’, ‘range_not_satisfiable’),

417: (‘expectation_failed’,),

418: (‘im_a_teapot’, ‘teapot’, ‘i_am_a_teapot’),

421: (‘misdirected_request’,),

422: (‘unprocessable_entity’, ‘unprocessable’),

423: (‘locked’,),

424: (‘failed_dependency’, ‘dependency’),

425: (‘unordered_collection’, ‘unordered’),

426: (‘upgrade_required’, ‘upgrade’),

428: (‘precondition_required’, ‘precondition’),

429: (‘too_many_requests’, ‘too_many’),

431: (‘header_fields_too_large’, ‘fields_too_large’),

444: (‘no_response’, ‘none’),

449: (‘retry_with’, ‘retry’),

450: (‘blocked_by_windows_parental_controls’, ‘parental_controls’),

451: (‘unavailable_for_legal_reasons’, ‘legal_reasons’),

499: (‘client_closed_request’,),

Server Error.

500: (‘internal_server_error’, ‘server_error’, ‘/o\’, ‘✗’),

501: (‘not_implemented’,),

502: (‘bad_gateway’,),

503: (‘service_unavailable’, ‘unavailable’),

504: (‘gateway_timeout’,),

505: (‘http_version_not_supported’, ‘http_version’),

506: (‘variant_also_negotiates’,),

507: (‘insufficient_storage’,),

509: (‘bandwidth_limit_exceeded’, ‘bandwidth’),

510: (‘not_extended’,),

511: (‘network_authentication_required’, ‘network_auth’, ‘network_authentication’),

高级操作

==============================================================

文件上传

自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。

深知大多数Python工程师,想要提升技能,往往是自己摸索成长或者是报班学习,但对于培训机构动则几千的学费,着实压力不小。自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!

因此收集整理了一份《2024年Python开发全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。
img
img



既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上Python开发知识点,真正体系化!

由于文件比较大,这里只是将部分目录大纲截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且后续会持续更新

如果你觉得这些内容对你有帮助,可以添加V获取:vip1024c (备注Python)
img

学好 Python 不论是就业还是做副业赚钱都不错,但要学会 Python 还是要有一个学习规划。最后大家分享一份全套的 Python 学习资料,给那些想学习 Python 的小伙伴们一点帮助!

一、Python所有方向的学习路线

Python所有方向路线就是把Python常用的技术点做整理,形成各个领域的知识点汇总,它的用处就在于,你可以按照上面的知识点去找对应的学习资源,保证自己学得较为全面。

二、学习软件

工欲善其事必先利其器。学习Python常用的开发软件都在这里了,给大家节省了很多时间。

三、全套PDF电子书

书籍的好处就在于权威和体系健全,刚开始学习的时候你可以只看视频或者听某个人讲课,但等你学完之后,你觉得你掌握了,这时候建议还是得去看一下书籍,看权威技术书籍也是每个程序员必经之路。

四、入门学习视频

我们在看视频学习的时候,不能光动眼动脑不动手,比较科学的学习方法是在理解之后运用它们,这时候练手项目就很适合了。

五、实战案例

光学理论是没用的,要学会跟着一起敲,要动手实操,才能将自己的所学运用到实际当中去,这时候可以搞点实战案例来学习。

六、面试资料

我们学习Python必然是为了找到高薪的工作,下面这些面试题是来自阿里、腾讯、字节等一线互联网大厂最新的面试资料,并且有阿里大佬给出了权威的解答,刷完这一套面试资料相信大家都能找到满意的工作。

一个人可以走的很快,但一群人才能走的更远。如果你从事以下工作或对以下感兴趣,欢迎戳这里加入程序员的圈子,让我们一起学习成长!

AI人工智能、Android移动开发、AIGC大模型、C C#、Go语言、Java、Linux运维、云计算、MySQL、PMP、网络安全、Python爬虫、UE5、UI设计、Unity3D、Web前端开发、产品经理、车载开发、大数据、鸿蒙、计算机网络、嵌入式物联网、软件测试、数据结构与算法、音视频开发、Flutter、IOS开发、PHP开发、.NET、安卓逆向、云计算

g_convert/6c361282296f86381401c05e862fe4e9.png)

一个人可以走的很快,但一群人才能走的更远。如果你从事以下工作或对以下感兴趣,欢迎戳这里加入程序员的圈子,让我们一起学习成长!

AI人工智能、Android移动开发、AIGC大模型、C C#、Go语言、Java、Linux运维、云计算、MySQL、PMP、网络安全、Python爬虫、UE5、UI设计、Unity3D、Web前端开发、产品经理、车载开发、大数据、鸿蒙、计算机网络、嵌入式物联网、软件测试、数据结构与算法、音视频开发、Flutter、IOS开发、PHP开发、.NET、安卓逆向、云计算

  • 20
    点赞
  • 23
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值