Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
requests, czyli HTTP dla ludzi
Search
Zbigniew Siciarz
July 11, 2011
Programming
1
110
requests, czyli HTTP dla ludzi
requests: HTTP for humans
My talk from PyWaw #2 (in Polish).
Zbigniew Siciarz
July 11, 2011
Tweet
Share
More Decks by Zbigniew Siciarz
See All by Zbigniew Siciarz
What if Socrates was a dev?
zsiciarz
0
110
Calling Rust from other languages
zsiciarz
3
620
An introduction to the Rust ecosystem
zsiciarz
5
1.8k
Python3-only Django project - the benefits
zsiciarz
1
330
My God, it's full of stars! (and planets and Python)
zsiciarz
0
3k
PostgreSQL & Django - a tasty mix
zsiciarz
2
410
Building an online PDF editor from scratch
zsiciarz
3
1k
IPython: tips, tricks & magic
zsiciarz
8
3.5k
ShiningPanda: simple CI hosting for Python
zsiciarz
1
100
Other Decks in Programming
See All in Programming
生成AIでGitHubソースコード取得して仕様書を作成
shukob
0
300
menu基盤チームによるGoogle Cloudの活用事例~Application Integration, Cloud Tasks編~
yoshifumi_ishikura
0
110
MCP with Cloudflare Workers
yusukebe
2
220
モバイルアプリにおける自動テストの導入戦略
ostk0069
0
110
talk-with-local-llm-with-web-streams-api
kbaba1001
0
180
たのしいparse.y
ydah
3
120
Criando Commits Incríveis no Git
marcelgsantos
2
170
複雑な仕様に立ち向かうアーキテクチャ
myohei
0
170
あれやってみてー駆動から成長を加速させる / areyattemite-driven
nashiusagi
1
200
Итераторы в Go 1.23: зачем они нужны, как использовать, и насколько они быстрые?
lamodatech
0
700
tidymodelsによるtidyな生存時間解析 / Japan.R2024
dropout009
1
760
アクターシステムに頼らずEvent Sourcingする方法について
j5ik2o
4
210
Featured
See All Featured
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
38
1.9k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
0
97
Automating Front-end Workflow
addyosmani
1366
200k
Scaling GitHub
holman
458
140k
Making the Leap to Tech Lead
cromwellryan
133
9k
How To Stay Up To Date on Web Technology
chriscoyier
789
250k
Gamification - CAS2011
davidbonilla
80
5.1k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
28
4.4k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
45
2.2k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
365
25k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
44
9.3k
The Pragmatic Product Professional
lauravandoore
32
6.3k
Transcript
httplib urllib(2) requests na ratunek requests, czyli HTTP dla ludzi
Zbigniew Siciarz PyWaw 11 lipca 2011 @zsiciarz requests, czyli HTTP dla ludzi
httplib urllib(2) requests na ratunek Plan prezentacji 1 httplib 2
urllib(2) 3 requests na ratunek @zsiciarz requests, czyli HTTP dla ludzi
httplib urllib(2) requests na ratunek httplib import httplib conn =
httplib.HTTPConnection("httpbin.org") conn.request("GET", "/status /418") response = conn.getresponse () print response.status , response.reason print response.read() @zsiciarz requests, czyli HTTP dla ludzi
httplib urllib(2) requests na ratunek httplib zbyszek@wicherek :~/ Dokumenty/requests$ python
code/httplib1.py 418 I’M A TEAPOT -=[ teapot ]=- _...._ .’ _ _ ‘. | ."‘ ^ ‘". _, \_;‘"---" ‘|// | ;/ \_ _/ ‘"""‘ @zsiciarz requests, czyli HTTP dla ludzi
httplib urllib(2) requests na ratunek urllib/urllib2 obie biblioteki w stdlib
@zsiciarz requests, czyli HTTP dla ludzi
httplib urllib(2) requests na ratunek urllib/urllib2 obie biblioteki w stdlib
ró»na funkcjonalno±¢ @zsiciarz requests, czyli HTTP dla ludzi
httplib urllib(2) requests na ratunek urllib/urllib2 obie biblioteki w stdlib
ró»na funkcjonalno±¢ urllib: kodowanie parametrów, pobieranie wprost do pliku @zsiciarz requests, czyli HTTP dla ludzi
httplib urllib(2) requests na ratunek urllib/urllib2 obie biblioteki w stdlib
ró»na funkcjonalno±¢ urllib: kodowanie parametrów, pobieranie wprost do pliku urllib2: obsªuga otwieraczy @zsiciarz requests, czyli HTTP dla ludzi
httplib urllib(2) requests na ratunek urllib2 - Basic Auth import
urllib2 url = ’http :// httpbin.org/basic -auth/user/pass’ user = ’user’ password = ’pass’ req = urllib2.Request(url) pwd_manager = urllib2.HTTPPasswordMgrWithDefaultRealm () pwd_manager.add_password(None , url , user , password) auth_manager = urllib2.HTTPBasicAuthHandler(pwd_manager) opener = urllib2.build_opener(auth_manager) urllib2.install_opener(opener) response = urllib2.urlopen(req) print response.getcode () print response.headers.getheader(’content -type’) print response.read() @zsiciarz requests, czyli HTTP dla ludzi
httplib urllib(2) requests na ratunek urllib2 - Basic Auth import
urllib2 url = ’http :// httpbin.org/basic -auth/user/pass’ user = ’user’ password = ’pass’ req = urllib2.Request(url) pwd_manager = urllib2.HTTPPasswordMgrWithDefaultRealm () pwd_manager.add_password(None , url , user , password) auth_manager = urllib2.HTTPBasicAuthHandler(pwd_manager) opener = urllib2.build_opener(auth_manager) urllib2.install_opener(opener) response = urllib2.urlopen(req) print response.getcode () print response.headers.getheader(’content -type’) print response.read() O RLY? @zsiciarz requests, czyli HTTP dla ludzi
httplib urllib(2) requests na ratunek requests http://python-requests.org/ Requests: Python HTTP
Module (That Doesn't Suck) @zsiciarz requests, czyli HTTP dla ludzi
httplib urllib(2) requests na ratunek requests http://python-requests.org/ Requests: Python HTTP
Module (That Doesn't Suck) Requests: The Simple (e.g. usable) HTTP Module @zsiciarz requests, czyli HTTP dla ludzi
httplib urllib(2) requests na ratunek requests http://python-requests.org/ Requests: Python HTTP
Module (That Doesn't Suck) Requests: The Simple (e.g. usable) HTTP Module Requests: HTTP for Humans @zsiciarz requests, czyli HTTP dla ludzi
httplib urllib(2) requests na ratunek requests - API requests.get(...) @zsiciarz
requests, czyli HTTP dla ludzi
httplib urllib(2) requests na ratunek requests - API requests.get(...) requests.post
@zsiciarz requests, czyli HTTP dla ludzi
httplib urllib(2) requests na ratunek requests - API requests.get(...) requests.post
requests.put @zsiciarz requests, czyli HTTP dla ludzi
httplib urllib(2) requests na ratunek requests - API requests.get(...) requests.post
requests.put requests.delete @zsiciarz requests, czyli HTTP dla ludzi
httplib urllib(2) requests na ratunek requests - API requests.get(...) requests.post
requests.put requests.delete requests.patch @zsiciarz requests, czyli HTTP dla ludzi
httplib urllib(2) requests na ratunek requests - API requests.get(...) requests.post
requests.put requests.delete requests.patch requests.options @zsiciarz requests, czyli HTTP dla ludzi
httplib urllib(2) requests na ratunek requests - API requests.get(...) requests.post
requests.put requests.delete requests.patch requests.options requests.head @zsiciarz requests, czyli HTTP dla ludzi
httplib urllib(2) requests na ratunek requests - proste »¡danie GET
import requests response = requests.get(’http :// httpbin.org/status /418’) print response.status_code print response.content @zsiciarz requests, czyli HTTP dla ludzi
httplib urllib(2) requests na ratunek requests - Basic Auth import
requests url = ’http :// httpbin.org/basic -auth/user/pass’ response = requests.get(url , auth=(’user’, ’pass’)) print response.status_code print response.headers[’content -type’] print response.content @zsiciarz requests, czyli HTTP dla ludzi
httplib urllib(2) requests na ratunek requests - Basic Auth zbyszek@wicherek
:~/ Dokumenty/requests$ python code/requests_2.py 2 application/json { "authenticated": true , "user": "user" } @zsiciarz requests, czyli HTTP dla ludzi
httplib urllib(2) requests na ratunek requests - POST i upload
pliku import requests data = dict(username=’’) with open(__file__) as f: response = requests.post(’http :// httpbin.org/post’, data=data , files ={’filename ’: f}) print response.status_code print response.content @zsiciarz requests, czyli HTTP dla ludzi
httplib urllib(2) requests na ratunek requests - POST i upload
pliku zbyszek@wicherek :~/ Dokumenty/requests$ python code/requests_3.py 2 { "origin": "::ffff :184.73.223.212", "files": { "filename": "import requests\n\n<CIACH >" }, "form": null , "url": "http :// httpbin.org/post", "args": {}, "headers": { "Content -Length": "555", <CIACH > "Content -Type": "multipart/form -data; boundary =3298 fc5c93854f96b712fa47 8e4cdef" }, "data": "username" } @zsiciarz requests, czyli HTTP dla ludzi
httplib urllib(2) requests na ratunek Alternatywy PyCURL wrapper na libcurl
@zsiciarz requests, czyli HTTP dla ludzi
httplib urllib(2) requests na ratunek Alternatywy PyCURL wrapper na libcurl
Mechanize klient to "przegl¡darka" @zsiciarz requests, czyli HTTP dla ludzi
httplib urllib(2) requests na ratunek The End Pytania? http://siciarz.net @zsiciarz
@zsiciarz requests, czyli HTTP dla ludzi