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
95
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
Pinia Colada が実現するスマートな非同期処理
naokihaba
4
220
ActiveSupport::Notifications supporting instrumentation of Rails apps with OpenTelemetry
ymtdzzz
1
230
AWS IaCの注目アップデート 2024年10月版
konokenj
3
3.3k
Laravel や Symfony で手っ取り早く OpenAPI のドキュメントを作成する
azuki
2
110
LLM生成文章の精度評価自動化とプロンプトチューニングの効率化について
layerx
PRO
2
190
距離関数を極める! / SESSIONS 2024
gam0022
0
280
TypeScript Graph でコードレビューの心理的障壁を乗り越える
ysk8hori
2
1.1k
광고 소재 심사 과정에 AI를 도입하여 광고 서비스 생산성 향상시키기
kakao
PRO
0
170
受け取る人から提供する人になるということ
little_rubyist
0
230
RubyLSPのマルチバイト文字対応
notfounds
0
120
A Journey of Contribution and Collaboration in Open Source
ivargrimstad
0
890
3 Effective Rules for Using Signals in Angular
manfredsteyer
PRO
1
100
Featured
See All Featured
Fashionably flexible responsive web design (full day workshop)
malarkey
405
65k
Raft: Consensus for Rubyists
vanstee
136
6.6k
Fantastic passwords and where to find them - at NoRuKo
philnash
50
2.9k
The Cult of Friendly URLs
andyhume
78
6k
The Cost Of JavaScript in 2023
addyosmani
45
6.7k
Scaling GitHub
holman
458
140k
Designing Experiences People Love
moore
138
23k
Into the Great Unknown - MozCon
thekraken
32
1.5k
Stop Working from a Prison Cell
hatefulcrawdad
267
20k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
26
2.1k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
191
16k
BBQ
matthewcrist
85
9.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