Download - 第5讲
![Page 2: 第5讲](https://reader036.vdocuments.pub/reader036/viewer/2022081412/5406e9938d7f72b90a8b4861/html5/thumbnails/2.jpg)
Python & Network
✤ 抓取一个网页
✤ 模拟浏览器行为,提交一些数据
✤ 刷校内之星
2009年9月25日金曜日
![Page 3: 第5讲](https://reader036.vdocuments.pub/reader036/viewer/2022081412/5406e9938d7f72b90a8b4861/html5/thumbnails/3.jpg)
twill
✤ http://twill.idyll.org/
✤ python setup.py install
✤ twill-sh
2009年9月25日金曜日
![Page 4: 第5讲](https://reader036.vdocuments.pub/reader036/viewer/2022081412/5406e9938d7f72b90a8b4861/html5/thumbnails/4.jpg)
twill
go http://www.renren.com/SysHome.doshowformsfv 1 email [email protected] 1 password xxxsubmitshow
登录校内
2009年9月25日金曜日
![Page 5: 第5讲](https://reader036.vdocuments.pub/reader036/viewer/2022081412/5406e9938d7f72b90a8b4861/html5/thumbnails/5.jpg)
twill
go http://upload.renren.com/addphotoPlain.do?id=327316943showformsformfile 3 photo1 /Users/fengqing/Downloads/p1.jpgsubmit
上传照片
2009年9月25日金曜日
![Page 6: 第5讲](https://reader036.vdocuments.pub/reader036/viewer/2022081412/5406e9938d7f72b90a8b4861/html5/thumbnails/6.jpg)
Python Network Library
✤ urllib
✤ httplib
✤ urllib2
✤ cookiejar
2009年9月25日金曜日
![Page 7: 第5讲](https://reader036.vdocuments.pub/reader036/viewer/2022081412/5406e9938d7f72b90a8b4861/html5/thumbnails/7.jpg)
urllib.urlopen(“http://www.sina.com.cn”).read()
2009年9月25日金曜日
![Page 8: 第5讲](https://reader036.vdocuments.pub/reader036/viewer/2022081412/5406e9938d7f72b90a8b4861/html5/thumbnails/8.jpg)
f = open(“c:/sina.html”,”w”)html = urllib.urlopen(“http://www.sina.com.cn”).read()f.write(html)f.close()
2009年9月25日金曜日
![Page 9: 第5讲](https://reader036.vdocuments.pub/reader036/viewer/2022081412/5406e9938d7f72b90a8b4861/html5/thumbnails/9.jpg)
cookiejar = cookielib.CookieJar()opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookiejar))params = {'email':'[email protected]','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日金曜日
![Page 10: 第5讲](https://reader036.vdocuments.pub/reader036/viewer/2022081412/5406e9938d7f72b90a8b4861/html5/thumbnails/10.jpg)
HTTP协议
✤ GET
✤ POST
✤ HEAD
✤ PUT/DELETE
2009年9月25日金曜日
![Page 11: 第5讲](https://reader036.vdocuments.pub/reader036/viewer/2022081412/5406e9938d7f72b90a8b4861/html5/thumbnails/11.jpg)
GET
✤ telnet www.renren.com 80
✤ GET / HTTP/1.0
2009年9月25日金曜日
![Page 12: 第5讲](https://reader036.vdocuments.pub/reader036/viewer/2022081412/5406e9938d7f72b90a8b4861/html5/thumbnails/12.jpg)
Cookie
✤ 小甜饼
✤ Cookie只存在本地电脑
✤ Cookie & 隐私
2009年9月25日金曜日
![Page 13: 第5讲](https://reader036.vdocuments.pub/reader036/viewer/2022081412/5406e9938d7f72b90a8b4861/html5/thumbnails/13.jpg)
Try
✤ 穷举密码,暴力破解
✤ 自动SQL注入程序
✤ WebGame外挂
2009年9月25日金曜日
![Page 14: 第5讲](https://reader036.vdocuments.pub/reader036/viewer/2022081412/5406e9938d7f72b90a8b4861/html5/thumbnails/14.jpg)
Free Time
✤ 利用这节课学到的知识,模拟浏览器行为,完成校内一些应用的自动操作
✤ 自动加好友
✤ 刷人气之星
✤ 自动投票
✤ 总去他/她的页面看看
✤ 自动提醒
2009年9月25日金曜日