spider_getModelInformation
import urllib
import urllib2
import re
class Spider:
def getPage(self,pageIndex):
url="http://mm.taobao.com/json/request_top_list.htm?page="+str(pageIndex)
request=urllib2.Request(url)
response=urllib2.urlopen(request)
return response.read().decode('gbk')
def getContents(self,pageIndex):
page=self.getPage(pageIndex)
pattern=re.compile('<a class="lady-name" href="(.*?)".*?>(.*?)</a>.*?<strong>(.*?)</strong>.*?<span>(.*?)</span>',re.S)
items=re.findall(pattern,page)
for item in items:
print "Personal Address",item[0]
print "Name",item[1],"Age",item[2],"city",item[3]
def start(self,start,end):
for i in range(start,end+1):
print "This is NO.",i,"model"
self.getContents(i)
spider=Spider()
spider.start(1,5)
spider_getModelInformation的更多相关文章
- 爬取字段和图片 spider_getModelInformation
import urllibimport urllib2import re class Spider: def getPage(self,pageIndex): url="http://mm. ...
随机推荐
- php请求返回GeoJSON格式的数据
<?php /* * Following code will list all the products */ // array for JSON response $response = ar ...
- CSS篇
一.盒子模型: 标准模式和混杂模式(IE).在标准模式下浏览器按照规范呈现页面:在混杂模式下,页面以一种比较宽松的向后兼容的方式显示.混杂模式通常模拟老式浏览器的行为以防止老站点无法工作. CSS盒子 ...
- 【转】使用:after清除浮动
以前总是加一个<div sytle="clear:both"></div>来解决,但这样会增加无语义的标签,下面是用after伪类实现,兼容多种浏览器.cl ...
- final finally finalize
final //如果不是final 的话,我可以在checkInt方法内部把i的值改变(有意或无意的, //虽然不会改变实际调用处的值),特别是无意的,可能会引用一些难以发现的BUG ...
- 《与小卡特一起学Python》Code3 抓取网页中的某个数据
import urllib2 file = urllib2.urlopen('http://common.cnblogs.com/script/jquery.js') message = file.r ...
- iOS runtime 初步学习
注: 在Xocde5之后, 使用运行时方法需要进行2步设置1. 在Build Setting中搜索'msg', 设置'Strict Checking' 为 NO2. 使用需要导入头文件 #import ...
- Android Fragment 深度解析
1.Fragment的产生与介绍 Android运行在各种各样的设备中,有小屏幕的手机,超大屏的平板甚至电视.针对屏幕尺寸的差距,很多情况下,都是先针对手机开发一套app,然后拷贝一份,修改布局以适应 ...
- Image放大缩小在放进Imageview
// 拿到要缩小放大的Bitmap obitmap = BitmapFactory.decodeResource(this.getResources(),R.drawable.ic_launcher) ...
- js流程控制题——如何实现一个LazyMan
先说一下想要的效果: lazyMan('zz').eat('lunch').sleep('3').eat('dinner')输出: Hi!This is zz! Eat lunch~ //有3s间隔等 ...
- Linux基础知识
1.url中不写端口号,默认就是80端口:本机是127.0.0.1或者localhost 2.用户管理 查看当前用户: id:可以查看当前用户:whoami:查看当前的用户:who:可以查看当前已经登 ...