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
アクターシステムに頼らずEvent Sourcingする方法について
j5ik2o
4
290
競技プログラミングへのお誘い@阪大BOOSTセミナー
kotamanegi
0
360
テストコード書いてみませんか?
onopon
2
140
Spatial Rendering for Apple Vision Pro
warrenm
0
110
テストコード文化を0から作り、変化し続けた組織
kazatohiei
2
1.5k
Effective Signals in Angular 19+: Rules and Helpers @ngbe2024
manfredsteyer
PRO
0
140
Mermaid x AST x 生成AI = コードとドキュメントの完全同期への道
shibuyamizuho
0
160
LLM Supervised Fine-tuningの理論と実践
datanalyticslabo
7
1.3k
たのしいparse.y
ydah
3
120
これが俺の”自分戦略” プロセスを楽しんでいこう! - Developers CAREER Boost 2024
niftycorp
PRO
0
190
バグを見つけた?それAppleに直してもらおう!
uetyo
0
180
20年もののレガシープロダクトに 0からPHPStanを入れるまで / phpcon2024
hirobe1999
0
510
Featured
See All Featured
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
111
49k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
32
2.7k
Writing Fast Ruby
sferik
628
61k
BBQ
matthewcrist
85
9.4k
Building Better People: How to give real-time feedback that sticks.
wjessup
365
19k
Building Flexible Design Systems
yeseniaperezcruz
327
38k
A better future with KSS
kneath
238
17k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
251
21k
How to Think Like a Performance Engineer
csswizardry
22
1.2k
Code Reviewing Like a Champion
maltzj
520
39k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
169
50k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.2k
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