# 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. 树莓派中GPIO针角定义图

    一.上图 二.上图

  2. Linux下使用Nohup后台运行程序

    一.不输出日志的命令 #!/bin/bash echo "starting nohup..." nohup dotnet ./mynetcoreapp.dll > /dev/ ...

  3. js 开源k线图开发库

    https://github.com/andredumas/techan.js/wiki http://techanjs.org/ A visual, stock charting (Candlest ...

  4. 在cmd中为命令设置别名以及启动cmd时自动执行bat

    http://www.cnblogs.com/fstang/archive/2013/04/06/3002006.html 简短步骤: 1.关闭所有在运行的CMD窗口 2.创建文件C:\cmd-ali ...

  5. adb remount 失败:remount failed: Operation not permitted

    adb remount 失败:remount failed: Operation not permitted     关于ADB的使用,这里再说明下:经常使用命令 adb shell - 登录设备sh ...

  6. JPress的CMS系统在Window下的部署和使用

    开始使用JPress系统的话首先要进入官网对其进行熟悉 官网网址如下:http://www.jpress.io/faq.html 然后是下载项目,项目下载地址是.https://gitee.com/f ...

  7. Eclipse Java注释模板设置详解以及版权声明

    网上的Eclipse注释模板,在这里稍稍整理一些比较常用的. 编辑注释模板的方法:Window->Preference->Java->Code Style->Code Temp ...

  8. DHCP 服务测试

    DHCP三个端口: 服务端:UDP 67 客户端:UDP 68 DHCPv6 客户端:UDP 546,这是需要特别开启的 DHCP failover 服务,用来做双机热备的. 实验一.DHCP服务器基 ...

  9. 聚集函数查询结果为空, list的size是1, resolve

    resultList.removeAll(Collections.singleton(null));

  10. spring 2种下载方式 下载地址 download 地址

    spring 在官网只提供 maven 的下载方式,把zip方式的不再提供,两种方法下载: 1.想找回以前版本的spring zip包,如果知道版本号,那么直接在google里输入 ” spring ...