SlideShare uma empresa Scribd logo
1 de 14
Baixar para ler offline
5
   qingfeng@me.com

   2009-09-26


2009   9   25
Python & Network



   ✤




   ✤            ,

   ✤




2009   9   25
twill



   ✤       http://twill.idyll.org/

   ✤       python setup.py install

   ✤       twill-sh




2009   9   25
twill


                go http://www.renren.com/SysHome.do
                showforms
                fv 1 email qingfeng@me.com
                fv 1 password xxx
                submit
                show




2009   9   25
twill


       go http://upload.renren.com/addphotoPlain.do?
       id=327316943
       showforms
       formfile 3 photo1 /Users/fengqing/Downloads/p1.jpg
       submit




2009   9   25
Python Network Library


   ✤       urllib

   ✤       httplib

   ✤       urllib2

   ✤       cookiejar




2009   9   25
urllib.urlopen(“http://www.sina.com.cn”).read()




2009   9   25
f = open(“c:/sina.html”,”w”)
                html = urllib.urlopen(“http://www.sina.com.cn”).read()
                f.write(html)
                f.close()




2009   9   25
cookiejar = cookielib.CookieJar()
 opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookiejar))
 params = {'email':'qingfeng@me.com','password':'xxx','origURL':"http://
 www.renren.com/SysHome.do"}
 data = urllib.urlencode(params)
 fobj = opener.open('http://passport.renren.com/PLogin.do', data)

 fobj = opener.open('http://renren.com/profile.do?id=260622588')
 print fobj.read()




2009   9   25
HTTP


   ✤       GET

   ✤       POST

   ✤       HEAD

   ✤       PUT/DELETE




2009   9   25
GET



   ✤       telnet www.renren.com 80

   ✤       GET / HTTP/1.0




2009   9   25
Cookie



   ✤




   ✤       Cookie

   ✤       Cookie &




2009   9   25
Try



   ✤                  ,

   ✤            SQL

   ✤       WebGame




2009   9   25
Free Time

   ✤                ,   ,

   ✤




   ✤




   ✤




   ✤            /

   ✤



2009   9   25

Mais conteúdo relacionado

Semelhante a 第5讲

前瞻性Web性能优化pwpo
前瞻性Web性能优化pwpo前瞻性Web性能优化pwpo
前瞻性Web性能优化pwpoMichael Zhang
 
Proactive Web Performance Optimization.(Marcel Duran)
Proactive Web Performance Optimization.(Marcel Duran)Proactive Web Performance Optimization.(Marcel Duran)
Proactive Web Performance Optimization.(Marcel Duran)Ontico
 
Websockets at tossug
Websockets at tossugWebsockets at tossug
Websockets at tossugclkao
 
Migrating existing monolith to serverless in 8 steps
Migrating existing monolith to serverless in 8 stepsMigrating existing monolith to serverless in 8 steps
Migrating existing monolith to serverless in 8 stepsYan Cui
 
Google Enterprise App Intro
Google Enterprise App IntroGoogle Enterprise App Intro
Google Enterprise App IntroJay Xu
 
いかにしてユーザ体験を保証するか
いかにしてユーザ体験を保証するかいかにしてユーザ体験を保証するか
いかにしてユーザ体験を保証するかSatoshi Takada
 
Web 2.0 Expo: Even Faster Web Sites
Web 2.0 Expo: Even Faster Web SitesWeb 2.0 Expo: Even Faster Web Sites
Web 2.0 Expo: Even Faster Web SitesSteve Souders
 
The Web Becomes Graceful
The Web Becomes GracefulThe Web Becomes Graceful
The Web Becomes Gracefulcolorhook
 
Web20expo 20080425
Web20expo 20080425Web20expo 20080425
Web20expo 20080425Media Gorod
 
Front End Website Optimization
Front End Website OptimizationFront End Website Optimization
Front End Website OptimizationGerard Sychay
 
Go Faster, Webmaster
Go Faster, WebmasterGo Faster, Webmaster
Go Faster, WebmasterMike Bailey
 
Go Faster, Webmasters
Go Faster, WebmastersGo Faster, Webmasters
Go Faster, WebmastersMike Bailey
 
Widget Summit 2008
Widget Summit 2008Widget Summit 2008
Widget Summit 2008Volkan Unsal
 
Amazon WS Overview
Amazon WS OverviewAmazon WS Overview
Amazon WS OverviewJay
 
Hand-on Resources II: Extending SCMSWeb
Hand-on Resources II: Extending SCMSWebHand-on Resources II: Extending SCMSWeb
Hand-on Resources II: Extending SCMSWebSugree Phatanapherom
 
Migrating existing monolith to serverless in 8 steps
Migrating existing monolith to serverless in 8 stepsMigrating existing monolith to serverless in 8 steps
Migrating existing monolith to serverless in 8 stepsYan Cui
 
Migrating existing monolith to serverless in 8 steps
Migrating existing monolith to serverless in 8 stepsMigrating existing monolith to serverless in 8 steps
Migrating existing monolith to serverless in 8 stepsYan Cui
 
An introduction to Zope Page Templates and their use outside of Zope (+Audio)
An introduction to Zope Page Templates and their use outside of Zope (+Audio)An introduction to Zope Page Templates and their use outside of Zope (+Audio)
An introduction to Zope Page Templates and their use outside of Zope (+Audio)Matt Hamilton
 

Semelhante a 第5讲 (20)

前瞻性Web性能优化pwpo
前瞻性Web性能优化pwpo前瞻性Web性能优化pwpo
前瞻性Web性能优化pwpo
 
Tc&Tt
Tc&TtTc&Tt
Tc&Tt
 
Proactive Web Performance Optimization.(Marcel Duran)
Proactive Web Performance Optimization.(Marcel Duran)Proactive Web Performance Optimization.(Marcel Duran)
Proactive Web Performance Optimization.(Marcel Duran)
 
Websockets at tossug
Websockets at tossugWebsockets at tossug
Websockets at tossug
 
Migrating existing monolith to serverless in 8 steps
Migrating existing monolith to serverless in 8 stepsMigrating existing monolith to serverless in 8 steps
Migrating existing monolith to serverless in 8 steps
 
Google Enterprise App Intro
Google Enterprise App IntroGoogle Enterprise App Intro
Google Enterprise App Intro
 
いかにしてユーザ体験を保証するか
いかにしてユーザ体験を保証するかいかにしてユーザ体験を保証するか
いかにしてユーザ体験を保証するか
 
Web 2.0 Expo: Even Faster Web Sites
Web 2.0 Expo: Even Faster Web SitesWeb 2.0 Expo: Even Faster Web Sites
Web 2.0 Expo: Even Faster Web Sites
 
The Web Becomes Graceful
The Web Becomes GracefulThe Web Becomes Graceful
The Web Becomes Graceful
 
Web20expo 20080425
Web20expo 20080425Web20expo 20080425
Web20expo 20080425
 
Front End Website Optimization
Front End Website OptimizationFront End Website Optimization
Front End Website Optimization
 
Go Faster, Webmaster
Go Faster, WebmasterGo Faster, Webmaster
Go Faster, Webmaster
 
Go Faster, Webmasters
Go Faster, WebmastersGo Faster, Webmasters
Go Faster, Webmasters
 
Widget Summit 2008
Widget Summit 2008Widget Summit 2008
Widget Summit 2008
 
Amazon WS Overview
Amazon WS OverviewAmazon WS Overview
Amazon WS Overview
 
Hand-on Resources II: Extending SCMSWeb
Hand-on Resources II: Extending SCMSWebHand-on Resources II: Extending SCMSWeb
Hand-on Resources II: Extending SCMSWeb
 
Migrating existing monolith to serverless in 8 steps
Migrating existing monolith to serverless in 8 stepsMigrating existing monolith to serverless in 8 steps
Migrating existing monolith to serverless in 8 steps
 
Migrating existing monolith to serverless in 8 steps
Migrating existing monolith to serverless in 8 stepsMigrating existing monolith to serverless in 8 steps
Migrating existing monolith to serverless in 8 steps
 
Josephj Yui Nctu 2
Josephj Yui Nctu 2Josephj Yui Nctu 2
Josephj Yui Nctu 2
 
An introduction to Zope Page Templates and their use outside of Zope (+Audio)
An introduction to Zope Page Templates and their use outside of Zope (+Audio)An introduction to Zope Page Templates and their use outside of Zope (+Audio)
An introduction to Zope Page Templates and their use outside of Zope (+Audio)
 

第5讲

  • 1. 5 qingfeng@me.com 2009-09-26 2009 9 25
  • 2. Python & Network ✤ ✤ , ✤ 2009 9 25
  • 3. twill ✤ http://twill.idyll.org/ ✤ python setup.py install ✤ twill-sh 2009 9 25
  • 4. twill go http://www.renren.com/SysHome.do showforms fv 1 email qingfeng@me.com fv 1 password xxx submit show 2009 9 25
  • 5. twill go http://upload.renren.com/addphotoPlain.do? id=327316943 showforms formfile 3 photo1 /Users/fengqing/Downloads/p1.jpg submit 2009 9 25
  • 6. Python Network Library ✤ urllib ✤ httplib ✤ urllib2 ✤ cookiejar 2009 9 25
  • 8. f = open(“c:/sina.html”,”w”) html = urllib.urlopen(“http://www.sina.com.cn”).read() f.write(html) f.close() 2009 9 25
  • 9. cookiejar = cookielib.CookieJar() opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookiejar)) params = {'email':'qingfeng@me.com','password':'xxx','origURL':"http:// www.renren.com/SysHome.do"} data = urllib.urlencode(params) fobj = opener.open('http://passport.renren.com/PLogin.do', data) fobj = opener.open('http://renren.com/profile.do?id=260622588') print fobj.read() 2009 9 25
  • 10. HTTP ✤ GET ✤ POST ✤ HEAD ✤ PUT/DELETE 2009 9 25
  • 11. GET ✤ telnet www.renren.com 80 ✤ GET / HTTP/1.0 2009 9 25
  • 12. Cookie ✤ ✤ Cookie ✤ Cookie & 2009 9 25
  • 13. Try ✤ , ✤ SQL ✤ WebGame 2009 9 25
  • 14. Free Time ✤ , , ✤ ✤ ✤ ✤ / ✤ 2009 9 25