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
96
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
400
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
RubyLSPのマルチバイト文字対応
notfounds
0
120
Macとオーディオ再生 2024/11/02
yusukeito
0
380
Contemporary Test Cases
maaretp
0
140
Duckdb-Wasmでローカルダッシュボードを作ってみた
nkforwork
0
130
3 Effective Rules for Using Signals in Angular
manfredsteyer
PRO
0
100
CSC509 Lecture 09
javiergs
PRO
0
140
ふかぼれ!CSSセレクターモジュール / Fukabore! CSS Selectors Module
petamoriken
0
150
Jakarta EE meets AI
ivargrimstad
0
640
Outline View in SwiftUI
1024jp
1
340
Why Jakarta EE Matters to Spring - and Vice Versa
ivargrimstad
0
1.2k
CSC509 Lecture 12
javiergs
PRO
0
160
デザインパターンで理解するLLMエージェントの作り方 / How to develop an LLM agent using agentic design patterns
rkaga
3
250
Featured
See All Featured
Navigating Team Friction
lara
183
14k
Side Projects
sachag
452
42k
Why Our Code Smells
bkeepers
PRO
334
57k
Being A Developer After 40
akosma
87
590k
How STYLIGHT went responsive
nonsquared
95
5.2k
Into the Great Unknown - MozCon
thekraken
32
1.5k
What's in a price? How to price your products and services
michaelherold
243
12k
Large-scale JavaScript Application Architecture
addyosmani
510
110k
The Art of Programming - Codeland 2020
erikaheidi
52
13k
It's Worth the Effort
3n
183
27k
Git: the NoSQL Database
bkeepers
PRO
427
64k
Automating Front-end Workflow
addyosmani
1366
200k
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