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的更多相关文章

  1. 爬取字段和图片 spider_getModelInformation

    import urllibimport urllib2import re class Spider: def getPage(self,pageIndex): url="http://mm. ...

随机推荐

  1. centos6安装python3.4和pip3

    在安装了epel源的情况下,直接yum就可以安装python3.4 yum install python34 -ypython3 --version 没有自带pip3,从官网安装 wget --no- ...

  2. Python3基础 访问列表 大于等于指定索引值的所有元素

    镇场诗:---大梦谁觉,水月中建博客.百千磨难,才知世事无常.---今持佛语,技术无量愿学.愿尽所学,铸一良心博客.------------------------------------------ ...

  3. 浏览器请求URL原理

    访问服务器url其实是访问DNS服务器,浏览器询问DNS服务器锁访问的url的IP是什么, 找到之后就会返回结果,找不到就继续去其他DNS中寻找,找到路径之后就会返回一个html文档,浏览器会解析这个 ...

  4. Spark在Hadoop集群上的配置(spark-1.1.0-bin-hadoop2.4)

    运行Spark服务,需要在每个节点上部署Spark. 可以先从主节点上将配置修改好,然后把Spark直接scp到其他目录. 关键配置 修改conf/spark-env.sh文件: export JAV ...

  5. What is the difference between routine , method , procedure , function ? please explain it with example?

    a method is named and attached to an object. so, for example, a method is like a function but is con ...

  6. spark的standlone模式安装和application 提交

    spark的standlone模式安装 安装一个standlone模式的spark集群,这里是最基本的安装,并测试一下如何进行任务提交. require:提前安装好jdk 1.7.0_80 :scal ...

  7. 虚拟机EAL: Error reading from file descriptor

    这个是虚拟机安装固有的BUG,代码差异如下: diff --git a/lib/librte_eal/linuxapp/igb_uio/igb_uio.c b/lib/librte_eal/linux ...

  8. 高并发下MySQL出现checking permissions

    在某些数据访问层框架中,会使用show full tables from test like 'demo',来检查数据库的状态.当数据库中表的数量较少时,并没有出现严重的问题.但是当数据库中的表数量多 ...

  9. 【转】PCI学习笔记

    1.PCI设备编号    每一个PCI device都有其unique PFA(PCI Fcntion Address)    PFA由 bus number.device number.functi ...

  10. pc端页面在移动端显示问题

    1.pc端页面在移动端显示,默认视口宽度是980px(也就是body宽度是980px),可通过meta标签设置为需要的尺寸,比如页面中元素最大宽度是1220px,则如下所示 <meta name ...