# 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. C# FTP常规方法

    using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using Sy ...

  2. Spring学习笔记五:Spring进行事务管理

    转载请注明原文地址:http://www.cnblogs.com/ygj0930/p/6776256.html  事务管理主要负责对持久化方法进行统一的提交或回滚,Spring进行事务管理即我们无需在 ...

  3. Java同步机制之Monitor监视器与syncrhoized实现原理

    转载请注意原文地址:http://www.cnblogs.com/ygj0930/p/6561667.html  一:Monitor Monitor是一个同步工具,相当于操作系统中的互斥量(mutex ...

  4. auto function -> return type 当不能从{}内推断类型时

    示例: template<class F, class... Args> auto ThreadPool::enqueue(F&& f, Args&&... ...

  5. Android内存分析命令(转)

    一.概述 1.1 内存指标概念 Item 全称 含义 等价 USS Unique Set Size 物理内存 进程独占的内存 PSS Proportional Set Size 物理内存 PSS= U ...

  6. MySQL中 PK NN UQ BIN UN ZF AI 的意思

    PK   Belongs to primary key作为主键 NN   Not Null非空 UQ  Unique index不能重复 BIN  Is binary column存放二进制数据的列 ...

  7. Cocos2d-x-Lua演示样例项目HelloLua

    Cocos2d-x-Lua演示样例项目HelloLua 本篇博客介绍Cocos2d-x中Lua的实例项目,就是使用Cocos2d-x创建的初始项目执行所呈现的农场,这里笔者取名为HelloLua.本篇 ...

  8. Inno Setup入门(二)——修改安装过程中的图片

    修改安装过程中的图片 一般编译之后,安装过程中出现在左边图片是是下图这个样子的: 其实也可以修改它,只需要在setup段中作一点稍微的修改,加一行代码即可: [setup] AppName=Test ...

  9. TL Cop

    第一讲 研发技术型人才的特点 一.为何要重视技术与研发技术管理 1.中国技术型企业近十年的发展路线图以及经验教训 2.技术还是营销:中国企业的痛 3.名家论技术与研发技术管理 二.研发技术人才的特点 ...

  10. Mongodb系列:初识Mongodb

    一.背景: 月初进行了期末考试非常荣幸可以參加到了考试系统维护中(详情请阅读:<那些年我们一起參加的活动:15年上半年考试系统维护总结>)!主要负责server维护,在维护期间对Mongo ...