# coding:utf-
from common.contest import * def spider():   url = "http://www.salamoyua.com/es/subasta.aspx?origen=subastas&subasta=79"
  
   chromedriver = 'C:/Users/xuchunlin/AppData/Local/Google/Chrome/Application/chromedriver.exe'
chome_options = webdriver.ChromeOptions()
   
  #使用代理 
# proxies = r.get('4')
# chome_options.add_argument(('--proxy-server=http://' + proxies)) os.environ["webdriver.chrome.driver"] = chromedriver
driver = webdriver.Chrome(chromedriver, chrome_options=chome_options) for i in range(1,100): print "正在爬取第" + str(i) + "页的数据" if i ==1:
# 请求url
driver.get(session_url)
result = driver.page_source
else:
try:
# 将页面滚动条拖到底部
js = "var q=document.documentElement.scrollTop=10000"
driver.execute_script(js)
driver.find_element_by_id('ctl00_phContenidos_lbSiguiente').click() # 得到爬取页面的结果
result = driver.page_source
time.sleep(3)
except:
result = "" soup = BeautifulSoup(result, 'html.parser')
result_div = soup.find_all('figure', attrs={"class": "Lotes fade"})
# print len(result_div)
for i in result_div:
      
         result_replace = replace(i)
print result_replace item_url = re.findall('<figure class="Lotes fade"><a href="(.*?)" id=',result_replace)[0]
item_url = "http://www.salamoyua.com/es/" + item_url.replace('','') item_imgurl = re.findall('<img id=".*?" src="..(.*?)" style="border-width:0px', result_replace)[0]
item_imgurl = "http://www.salamoyua.com" + item_imgurl.replace('', '') if "Remate" not in result_replace:
sold_price = ""
else:
sold_price = re.findall('<p><strong>Remate:(.*?)</strong></p></figcaption>', result_replace)[0]
sold_price = sold_price.replace(' ','') try: item_lotnum = re.findall('title="Lote vendido"><span id=".*?">(.*?)</span>', result_replace)[0]
item_lotnum = item_lotnum.replace('Lote','').replace(' ','')
except:
item_lotnum = re.findall('<span id=".*?">(.*?)</span></header>',result_replace)[0]
item_lotnum = item_lotnum.replace('Lote', '').replace(' ', '') print item_url
print item_lotnum
print item_imgurl
print sold_price
  

spider()

Python 爬虫实例(12)—— python selenium 爬虫的更多相关文章

  1. python小实例一:简单爬虫

    本文所谓的爬虫就是通过本地远程访问url,然后将url的读成源代码形式,然后对源代码进行解析,获取自己需要的数据,相当于简单数据挖掘.本文实现的是将一个网页的图片爬出保存到本地的过程,例子很简单,用的 ...

  2. python爬虫实例——基于python实现有道云翻译接口

    # 分析包# 分析post请求中参数# 使用python模拟lts.sign.salt参数运算# 执行结果> > 1.按F12对网页进行分析,填写内容后自动翻译的功能一般是通过ajax实现 ...

  3. Python 爬虫实例(11)—— 爬虫 苏宁易购

    # coding:utf-8 import json import redis import time import requests session = requests.session() imp ...

  4. 转:Scrapy安装、爬虫入门教程、爬虫实例(豆瓣电影爬虫)

    Scrapy在window上的安装教程见下面的链接:Scrapy安装教程 上述安装教程已实践,可行.(本来打算在ubuntu上安装Scrapy的,但是Ubuntu 磁盘空间太少了,还没扩展磁盘空间,所 ...

  5. Scrapy安装、爬虫入门教程、爬虫实例(豆瓣电影爬虫)

    Scrapy在window上的安装教程见下面的链接:Scrapy安装教程 上述安装教程已实践,可行.(本来打算在ubuntu上安装Scrapy的,但是Ubuntu 磁盘空间太少了,还没扩展磁盘空间,所 ...

  6. Python学习:12.Python字符串格式化

    字符串格式化 讲解Python这么久,也没有讲解Python的字符串的格式化,那我们今天就来了解一下python字符串格式化的强大之处. 首先我们先理解一下为什么要有字符串的格式化,就是为了方便字符串 ...

  7. shell及Python爬虫实例展示

    1.shell爬虫实例: [root@db01 ~]# vim pa.sh #!/bin/bash www_link=http://www.cnblogs.com/clsn/default.html? ...

  8. 小白学 Python 爬虫(40):爬虫框架 Scrapy 入门基础(七)对接 Selenium 实战

    人生苦短,我用 Python 前文传送门: 小白学 Python 爬虫(1):开篇 小白学 Python 爬虫(2):前置准备(一)基本类库的安装 小白学 Python 爬虫(3):前置准备(二)Li ...

  9. Python 爬虫实例

    下面是我写的一个简单爬虫实例 1.定义函数读取html网页的源代码 2.从源代码通过正则表达式挑选出自己需要获取的内容 3.序列中的htm依次写到d盘 #!/usr/bin/python import ...

  10. python Cmd实例之网络爬虫应用

    python Cmd实例之网络爬虫应用 标签(空格分隔): python Cmd 爬虫 废话少说,直接上代码 # encoding=utf-8 import os import multiproces ...

随机推荐

  1. 第八周(3) Word2007样式

    第八周(3) Word2007样式 教学时间 2013-4-19 教学课时 2 教案序号 23 教学目标 1.掌握样式的概念2.能够熟练地创建样式.修改样式的格式,使用样式3.熟练利用样式格式化文档 ...

  2. vsphere 处理NUMA

    vsphere 4.1 之前: cpu调度会将一个VM的分配给一个home node,整个vm被看做一个NUMA client. 如果VM的vCPU数量超过一个NUMA node的可用数量,则不被看做 ...

  3. 再谈IE的浏览器模式和文档模式[转]

    http://www.cnblogs.com/liuzhendong/archive/2012/04/27/2474363.html 以前在 “IE8兼容视图(IE7 mode)与独立IE7的区别”一 ...

  4. 【PMP】财务测量指标ROI、PBP、NPV、IRR、BCR

    各指标说明: 1.投资回报率(ROI) 定义:是指通过投资而应返回的价值,即企业从一项投资活动中得到的经济回报. 1.1 年平均利润相等的情况下 公式:ROI=年平均利润/投资额 案例: 1.2 年平 ...

  5. codevs 3083 二叉树

    题目描述 Description 同学们都知道二叉树的定义,也都知道3个结点的二叉树有5种, 现给你二叉树的结点个数n,要你编程输出不同形态二叉树的种数. 输入描述 Input Description ...

  6. 使用mapreduce来分析网站的log日志

    近日,有人和我说分析log日志. 之前,就写过,但是忘了总结了,找了半天也没有找到,看了以后要将东西整理了. 无奈,在网上收拾,看到这个人写的,索性,就搬过来,待我找到我写的,在一块补充一下! 所有网 ...

  7. Ubuntu16.04 Arduino UNO R3开发板

    使用的是国内改过的版本, usb芯片换成了ch341, 晶振不是原版的16MHz而是12MHz, 杜邦线孔布局和原版一致. 设备连接 在Ubuntu16.04下不需要驱动, 能直接认出ch341设备 ...

  8. OpenWRT/LEDE长期运行记录截图

    哈哈, 发图留念. 待会儿要把它换到别处去了. 在Newifi Y1上稳定运行了95天的自编译OpenWrt, Y1这个型号的特点是5G信号强度比2.4G的强 Update 2017-11-27 在W ...

  9. 网页屏蔽Backspace事件,输入框不屏蔽

    document.onkeydown = function (e) { var code; if (!e){ var e = window.event;} if (e.keyCode){ code = ...

  10. jquery版本号升级不兼容的问题:$(&quot;input&quot;).attr(&quot;value&quot;)功能发生改变

    之前项目中使用的是jquery-1.6.3.js,在这个版本号中,假设我们想获取输入框的值,能够使用$("input").attr("value")或者是$(& ...