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
90
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
Java ジェネリクス入門 2024
nagise
0
610
LLM生成文章の精度評価自動化とプロンプトチューニングの効率化について
layerx
PRO
2
140
ECS Service Connectのこれまでのアップデートと今後のRoadmapを見てみる
tkikuc
2
210
Hotwire or React? ~Reactの録画機能をHotwireに置き換えて得られた知見~ / hotwire_or_react
harunatsujita
9
4.1k
qmuntal/stateless のススメ
sgash708
0
120
Generative AI Use Cases JP (略称:GenU)奮闘記
hideg
0
160
外部システム連携先が10を超えるシステムでのアーキテクチャ設計・実装事例
kiwasaki
1
230
生成 AI を活用した toitta 切片分類機能の裏側 / Inside toitta's AI-Based Factoid Clustering
pokutuna
0
610
Snowflake x dbtで作るセキュアでアジャイルなデータ基盤
tsoshiro
2
440
リリース8年目のサービスの1800個のERBファイルをViewComponentに移行した方法とその結果
katty0324
5
3.6k
RailsのPull requestsのレビューの時に私が考えていること
yahonda
5
1.7k
Why Spring Matters to Jakarta EE - and Vice Versa
ivargrimstad
0
1k
Featured
See All Featured
Embracing the Ebb and Flow
colly
84
4.4k
Art, The Web, and Tiny UX
lynnandtonic
296
20k
Large-scale JavaScript Application Architecture
addyosmani
510
110k
KATA
mclloyd
29
13k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
131
33k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.1k
RailsConf 2023
tenderlove
29
880
The Art of Programming - Codeland 2020
erikaheidi
51
13k
Testing 201, or: Great Expectations
jmmastey
38
7k
Navigating Team Friction
lara
183
14k
Learning to Love Humans: Emotional Interface Design
aarron
272
40k
The Language of Interfaces
destraynor
154
24k
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