# 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. MySql SqlServer Sqlite中关于索引的创建

    最近要更新Cocon90.Db库,令其ORM创建表时实现索引的添加.因此总结下列常用Sql,供大家学习与参考. 一.SqlServer中创建索引可以这样: ) Create Table Test ( ...

  2. POSTGRESQL表分区

    最近发现POSTGRESQL的一张表(下面统称为test表)达到67G大小,不得不进行重新分区,下面记录一下步骤: 前言.查看数据表结构(表结构肯定是虚构的) CREATE TABLE test ( ...

  3. shell alias添加别名使用

    大家一定知道SHELL的基本用法,那么著名的命令:`ll`是代表`ls -l`,那么是怎么实现的哪?其实是添加了一个别名alias ll="ls -l" 我使用alias最多的地方 ...

  4. C语言之函数调用06—彩球排列

    //函数调用+递归法 /* ========================================================== 题目:将4个红球,3个白球.3个黄球排成一排,共同拥有 ...

  5. Python学习摘录(下)

    常用内建模块 1:collections模块:集合模块,提供了许多有用的集合类. namedtuple namedtuple是一个函数,它用来创建一个自定义的tuple对象,并且规定了tuple元素的 ...

  6. Java多线程之ReadWriteLock读写锁简介与使用教程

    转载请注明原文地址:http://www.cnblogs.com/ygj0930/p/6558073.html  普通的锁在对某一内容加锁后,其他线程是不能访问的.但是我们要考虑这种情况:如果当前加锁 ...

  7. Artistic Style在windows下的使用(C/C++)

    ArtisticStyle是一个开源的源码格式化工具.主页地址为:http://astyle.sourceforge.net/,它能够应用在C.C++.Objective-C.C#.Java等程序语言 ...

  8. oracle 判断字符串是否包含指定内容

      1.情景展示 如何将表中的包含特殊字符的脏数据查出来? 2.instr()函数 语法: instr(string, substring[, start_position[, th_appearan ...

  9. 通过ribbon 根据服务名获取所有服务实例的IP和端口列表

    代码使用SpringCloud版本E3 业务场景: 今天遇到一个业务场景,要求根据服务名获取当前微服务集群中所有的对应服务实例的IP和端口,通过分析源码推算出了写法. 原理简述: 如果代码中引入了sp ...

  10. CentOS7下HTTP并发测试工具Apache Benchmark(AB)安装和使用

    安装: yum -y install httpd-tools 使用: ab -c -n http://10.255.67.60:1111/info -c 并发数,concurrency -n 发送多少 ...