精华内容
下载资源
问答
  • 爬虫程序,实现金融数据抓取,能够进行在线抓取金融数据
  • 爬虫程序,实现金融数据抓取,能够进行在线抓取金融数据
  • 二、实现代码clc,clear %% % 设置不用科学计数法显示数据 format short g % % % 读取源代码 sourcefile=urlread('file:///D:/Program%20Files/MATLAB/R2013a/gui3/sheet.html'); % 正则表达式获取第一行数据存为...

    一、需求分析
    抓取内容:
    这里写图片描述

    二、实现代码

    clc,clear
    %%
    % 设置不用科学计数法显示数据
    format short g
    % % 
    % 读取源代码
    sourcefile=urlread('file:///D:/Program%20Files/MATLAB/R2013a/gui3/sheet.html');
    % 正则表达式获取第一行数据存为data1
    expr1='<td .*?>(.*?)</td>';
    
    [datafile1, data_tokens1] = regexp(sourcefile, expr1, 'match', 'tokens');
    data1 = zeros(size(data_tokens1));
    for idx1 = 1:length(data_tokens1)
    data1(idx1) = str2double(data_tokens1{idx1}{1});
    end
    
    %正则表达式获取第二行到最后一行存为data2
    expr2='<td>(.*?)</td>';
    [datafile2, data_tokens2] = regexp(sourcefile, expr2, 'match', 'tokens');
    data2 = zeros(size(data_tokens2));
    for idx2 = 16:length(data_tokens2)
    data2(idx2) = str2double(data_tokens2{idx2}{1});
    end
    data2=data2(1,16:end);
    % 合并data1和data2
    data3=[data1 data2];
    %%得到每个变量的数据
    number=data3(1,1:15:end)';
    Month=data3(1,2:15:end)';
    Day=data3(1,3:15:end)';
    Time=data3(1,4:15:end)';
    p=data3(1,5:15:end)';
    a=data3(1,6:15:end)';
    v=data3(1,7:15:end)';
    T=data3(1,8:15:end)';
    Cp=data3(1,9:15:end)';
    s=data3(1,10:15:end)';
    t1=data3(1,11:15:end)';
    S=data3(1,12:15:end)';
    H=data3(1,13:15:end)';
    P=data3(1,14:15:end)';
    n=data3(1,15:15:end)';
    % 转换成矩阵
    data4=[number Month Day Time p a v T Cp s t1 S H P n]
    展开全文
  • 如何利用matlab爬虫抓数据

    万次阅读 多人点赞 2015-12-27 11:53:55
    如何利用matlab爬虫抓包很多同学可能听说用python进行网上爬虫,今天给大家带来的是利用matlab爬虫。不需任何基础,意在给大家一种自己动手抓包的体验。 打开你安装好的matlab。 新建一个脚本文件,将以下代码复制...

    如何利用matlab爬虫抓包

    很多同学可能听说用python进行网上爬虫,今天给大家带来的是利用matlab爬虫。不需任何基础,意在给大家一种自己动手抓包的体验。

    1. 打开你安装好的matlab。
    2. 新建一个脚本文件,将以下代码复制黏贴进去。
    clc;
    clear;
    warning off;
    year=2015;    
    for season = 1:4   
    fprintf('抓取%d年%d季度的数据中...', year, season)
    [sourcefile, status] = urlread(sprintf('http://vip.stock.finance.sina.com.cn/corp/go.php/vMS_MarketHistory/stockid/000001/type/S.phtml?year=%d&season=%d', year));
    if ~status%判断数据是否全部读取成功
    error('出问题了哦,请检查\n')
    end
    expr1 = '\s+(\d\d\d\d-\d\d-\d\d)\s*';    %要提取的模式,()中为要提取的内容
    [datefile, date_tokens]= regexp(sourcefile, expr1, 'match', 'tokens');   %match返回整个匹配类型,token返回()标记的位置,都为元胞类型
    date = cell(size(date_tokens));%创建一个等大的元胞数组
    for idx = 1:length(date_tokens)
        date{idx} = date_tokens{idx}{1};    %将日期写入
    end
    expr2 = '<div align="center">(\d*\.?\d*)</div>';
    [datafile, data_tokens] = regexp(sourcefile, expr2, 'match', 'tokens'); %从源文件中获取目标数据
    data = zeros(size(data_tokens));%产生和数据相同长度的0
    for idx = 1:length(data_tokens)
        data(idx) = str2double(data_tokens{idx}{1});       %转变数据类型后存入data中
    end
    
    data = reshape(data, 6, length(data)/6 )'; %重排,根据源代码的显示,将不同定义的数据排成六列 
    items={'日期' '开盘价' '最高价' '收盘价' '最低价' '交易量' '交易金额'};
    sheet = sprintf('%d季度', season); %工作表名称
    xlswrite('D:/data', items, sheet)
    xlswrite('D:/data', date' , sheet,'A2'); %在第一列写入日期
    range = sprintf('B2:%s%d',char(double('B')+size(data,2)-1), size(data,1)+1); %从源文件中获取的目标数据的放置范围
    xlswrite('D:/data', data, sheet, range);
    fprintf('完成!\n')
    end
    
    
    fprintf('全部完成!数据保存在D盘的data表格中,请注意查看!\n')
    

    3.静静地等待,提示完成后,打开D盘的data表格,查看你的成果吧。

    有好奇心的同学,可能还想探索一下具体的工作机制,这可能就需要下苦工了,有以下几点建议

    • 学着看懂代码,不懂的地方上网搜索。自己摸索才是最好的学习方式,小编就不详述了。
    • 看懂代码并学会正则表达式后,打开网页源代码。
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>上证综合指数(000001)_历史交易_新浪网</title>
    <meta name="Keywords" content="上证综合指数,000001,行情" />
    <meta name="Description" content="上证综合指数的实时行情" />
    <link media="all" rel="stylesheet" href="/corp/view/css/style.css" />
    <link media="all" rel="stylesheet" href="/corp/view/css/newstyle.css" />
    <link media="all" rel="stylesheet" href="/corp/view/css/tables.css" />
    <link media="all" rel="stylesheet" href="/corp/view/css/style4.css" />
    <style type="text/css">
    body,ul,ol,li,p,h1,h2,h3,h4,h5,h6,form,fieldset,table,td,img,div{margin:0;padding:0;border:0;}
    body,ul,ol,li,p,form,fieldset,table,td{font-family:"宋体";}
    body{background:#fff;color:#000;}
    td,p,li,select,input,textarea,div{font-size:12px;}
    
    ul{list-style-type:none;}
    select,input{vertical-align:middle; padding:0; margin:0;}
    
    .f14 {font-size:14px;}
    .lh20 {line-height:20px;}
    .lh23{line-height:23px;}
    .b1{border:1px #fcc solid;}
    
    a{text-decoration: underline;color:#009}
    a:visited{color:#333333;}
    a:hover{color:#f00;}
    
    .f14links{line-height:23px;}
    .f14links,.f14links a{font-size:14px;color:#009;}
    .f14links a:hover{color:#F00;}
    .f14links li{padding-left:13px;background:url(http://image2.sina.com.cn/dy/legal/2006index/news_law_hz_012.gif) no-repeat 3px 45%;}
    
    .clearit{clear:both;font-size:0;line-height:0;height:0;}
    .STYLE2 {font-size: 14px; font-weight: bold; }
    
    /*杜邦分析用到的css begin*/
    .bottom_line {border-bottom:1px solid #999999}
    .f14 {font-size:14px}
    .f12 {font-size:12px}
    
    .l15{line-height:150%}
    .l13{line-height:130%}
    .lh19{line-height:19px;}
    /*杜邦分析用到的css end*/
    </style>
    <!--[if IE]>
    <link media="all" rel="stylesheet" href="http://www.sinaimg.cn/cj/realstock/css/ie.css" />
    <![endif]-->
    <script language="javascript" type="text/javascript">
    <!--//--><![CDATA[//><!--
    var fullcode="sh000001";
    var chart_img_alt = "上证综合指数 000001 行情图";
    
    /* comment */
    var cmnt_channel    = "gg";
    var cmnt_newsid     = "sh-000001";
    var cmnt_group      = 1;
    
    var detailcache = new Array();
    //--><!]]>
    </script>
    <script type="text/javascript" src="/corp/view/js/all.js"></script>
    <script type="text/javascript" src="/corp/view/js/tables.js"></script>
    
    <script type="text/javascript" src="http://finance.sina.com.cn/iframe/hot_stock_list.js"></script>
    <script type="text/javascript" src="http://hq.sinajs.cn/list=sh000001,s_sh000001,s_sh000300,s_sz399001,s_sz399106,s_sz395099"></script>
    <script type="text/javascript" src="http://image2.sina.com.cn/home/sinaflash.js"></script>
    
    <script type="text/javascript" src="/corp/view/js/corp_fenshi_zs.js"></script> 
    
    </head>
    <body>
    
    <div id="wrap">
    <!-- 标准二级导航_财经 begin -->
    <style type="text/css">
    .secondaryHeader{height:33px;overflow:hidden;background:url(http://i2.sinaimg.cn/dy/images/header/2008/standardl2nav_bg.gif) repeat-x #fff;color:#000;font-size:12px;font-weight:100;}
    .secondaryHeader a,.secondaryHeader a:visited{color:#000;text-decoration:none;}
    .secondaryHeader a:hover,.secondaryHeader a:active{color:#c00;text-decoration:underline;}
    .sHBorder{border:1px #e3e3e3 solid;padding:0 10px 0 12px;overflow:hidden;zoom:1;}
    .sHLogo{float:left;height:31px;line-height:31px;overflow:hidden;}
    .sHLogo span,.sHLogo span a,.sHLogo span a:link,.sHLogo span a:visited,.sHLogo span a:hover{display:block;*float:left;display:table-cell;vertical-align:middle;*display:block;*font-size:27px;*font-family:Arial;height:31px;}
    .sHLogo span,.sHLogo span a img,.sHLogo span a:link img,.sHLogo span a:visited img,.sHLogo span a:hover img{vertical-align:middle;}
    .sHLinks{float:right;line-height:31px;}
    #level2headerborder{background:#fff; height:5px; overflow:hidden; clear:both; width:950px;}
    </style>
    <div id="level2headerborder"></div>
    <div class="secondaryHeader">
        <div class="sHBorder">
            <div class="sHLogo"><span><a href="http://www.sina.com.cn/"><img src="http://i1.sinaimg.cn/dy/images/header/2009/standardl2nav_sina_new.gif" alt="新浪网" /></a><a href="http://finance.sina.com.cn/"><img src="http://i1.sinaimg.cn/dy/images/header/2009/standardl2nav_finance.gif" alt="新浪财经" /></a></span></div>
            <div class="sHLinks"><a href="http://finance.sina.com.cn/">财经首页</a>&nbsp;|&nbsp;<a href="http://www.sina.com.cn/">新浪首页</a>&nbsp;|&nbsp;<a href="http://news.sina.com.cn/guide/">新浪导航</a></div>
        </div>
    </div>
    <div id="level2headerborder"></div>
    <!-- 标准二级导航_财经 end -->
      <!-- banner begin -->
      <div style="float:left; width:950px;">
        <!-- 顶部广告位 begin -->
        <div style="float:left; width:750px; height:90px;">
            <iframe marginheight="0" marginwidth="0" src="http://finance.sina.com.cn/iframe/ad/PDPS000000004094.html" frameborder="0" height="90" scrolling="no" width="750"></iframe><!--<script type="text/javascript" src="http://finance.sina.com.cn/pdps/js/PDPS000000004094.js"></script> --> 
        </div>
        <!-- 顶部广告位 end -->
        <div style="float:right;width:188px; height:88px; border:1px solid #DEDEDE;">
            <ul>
                <li style="background:url(http://www.sinaimg.cn/bb/article/con_ws_001.gif);line-height:15px;text-align:center;color:#F00">热点推荐</li>
    
                <li style="line-height:20px; margin-top:5px;">·<a href="http://vip.stock.finance.sina.com.cn/portfolio/main.php" style="color:#F00">自选股-轻松管理您的千只股票</a></li>
    
                <li style="line-height:20px;">·<a href="http://finance.sina.com.cn/money/mall.shtml">金融e路通-理财投资更轻松</a></li>
                <li style="line-height:20px;">·<a href="http://biz.finance.sina.com.cn/hq/">行情中心-通往财富之门</a></li>
            </ul>
        </div>
        <div style="clear:both"></div>
    
      </div>
    
      <!-- banner end -->
      <div class="HSpace-1-5"></div>
      <!-- 导航 begin -->
      <div class="nav">
        <ul>
          <li class="navRedLi"><a href="http://finance.sina.com.cn/" target="_blank">财经首页</a></li>
          <li id="nav01"><a href="http://finance.sina.com.cn/stock/index.shtml" target="_blank">股票</a></li>
          <li id="nav02"><a href="http://finance.sina.com.cn/fund/index.shtml" target="_blank">基金</a></li>
          <li id="nav03"><a href="http://finance.sina.com.cn/stock/roll.shtml" target="_blank">滚动</a></li>
          <li id="nav04"><a href="http://vip.stock.finance.sina.com.cn/corp/view/vCB_BulletinGather.php" target="_blank">公告</a></li>
          <li id="nav05"><a href="http://finance.sina.com.cn/column/jsy.html" target="_blank">大盘</a></li>
          <li id="nav06"><a href="http://finance.sina.com.cn/column/ggdp.html" target="_blank">个股</a></li>
          <li id="nav07"><a href="http://finance.sina.com.cn/stock/newstock/index.shtml" target="_blank">新股</a></li>
          <li id="nav08"><a href="http://finance.sina.com.cn/stock/warrant/index.shtml" target="_blank">权证</a></li>
          <li id="nav09"><a href="http://finance.sina.com.cn/stock/reaserchlist.shtml" target="_blank">报告</a></li>
          <li id="nav10"><a href="http://finance.sina.com.cn/money/globalindex/index.shtml" target="_blank">环球市场</a></li>   
          <li id="nav11"><a href="http://blog.sina.com.cn/lm/finance/index.html" target="_blank">博客</a></li>
          <li id="nav12"><a href="http://finance.sina.com.cn/bar/" target="_blank">股票吧</a></li>
          <li id="nav13"><a href="http://finance.sina.com.cn/stock/hkstock/index.shtml" target="_blank">港股</a></li>
          <li id="nav14"><a href="http://finance.sina.com.cn/stock/usstock/index.shtml" target="_blank">美股</a></li>      
          <li id="nav15"><a href="http://biz.finance.sina.com.cn/hq/" target="_blank">行情中心</a></li>
          <li id="nav16"><a href="http://vip.stock.finance.sina.com.cn/portfolio/main.php" target="_blank">自选股</a></li>
       </ul>
      </div>
      <!-- 导航 end -->
      <!-- 导航下 begin -->
      <div class="navbtm">
        <div class="navbtmblk1"><span id="idxsh000001"><a href="http://finance.sina.com.cn/realstock/company/sh000001/nc.shtml" target="_blank">上证指数</a>: 0000.00 0.00 00.00亿元</span> | <span id="idxsz399001"><a href="http://finance.sina.com.cn/realstock/company/sz399001/nc.shtml" target="_blank">深圳成指</a>: 0000.00 0.00 00.00亿元</span> | <span id="idxsh000300"><a href="http://finance.sina.com.cn/realstock/company/sh000300/nc.shtml" target="_blank">沪深300</a>: 0000.00 0.00 00.00亿元</span></div>
    
        <div class="navbtmmaquee">
          <script type="text/javascript" src="http://finance.sina.com.cn/286/20061129/3.js"></script>
          <script type="text/javascript" language="javascript">
            <!--//--><![CDATA[//><!--
            if(!document.layers) {
                with (document.getElementsByTagName("marquee")[0]) {
                    scrollDelay = 50;
                    scrollAmount = 2;
                    onmouseout = function () {
                        this.scrollDelay = 50;
                    };
                }
            }
            //--><!]]>
          </script>
        </div>
      </div>
      <!-- 导航下 end -->
      <div class="HSpace-1-6"></div>
    
      <div id="main">
    
        <!-- 左侧 begin -->
        <div id="left">
          <!-- 最近访问股|我的自选股 begin -->
          <div class="LBlk01">
            <!-- 标签 begin -->
            <ul class="LTab01">
              <li class="Menu01On" id="m01-0">最近访问股</li>
    
              <li class="Menu01Off" id="m01-1">我的自选股</li>
    
            </ul>
            <!-- 标签 end -->
            <!-- 内容 begin -->
            <div id="con01-0"></div>
            <div id="con01-1" style="display:none;"></div>
            <!-- 内容 end -->
          </div>
    
          <!-- 最近访问股|我的自选股 end -->
          <div class="HSpace-1-10"></div>
    
          <!-- 菜单 begin -->
          <div class="Menu-Ti" id="navlf00"><img src="http://www.sinaimg.cn/cj/realstock/image2/finance_in_ws_010.gif" alt="" id="tImg0"/><span class="capname">每日必读</span></div>
          <div class="Menu-Con" id="item0" style="display:block;">
            <table cellspacing="0">
              <tr>
                <td>·<a href="http://stock.finance.sina.com.cn/" target="_self">股市必察</a></td>
    
                <td>·<a href="http://biz.finance.sina.com.cn/stock/company/notice.php?kind=daily" target="_self" class="incolor">每日提示</a></td>
    
              </tr>
              <tr>
                <td>·<a href="/corp/go.php/vRPD_QuickView/.phtml" target="_self">公司快报</a></td>
                <td>·<a href="/corp/go.php/vRPD_NewStockIssue/page/1.phtml" target="_self">新股上市</a></td>
    
              </tr>
              <tr>
                <td>·<a href="http://vip.stock.finance.sina.com.cn/q/go.php/vInvestConsult/kind/lhb/index.phtml" target="_self">龙虎榜</a></td>
    
                <td>·<a href="http://vip.stock.finance.sina.com.cn/q/go.php/vIR_EndRise/index.phtml" target="_self" class="incolor">每日热股</a></td>
              </tr>
              <tr>
    
                <td colspan='2'>·<a href="http://finance.sina.com.cn/realstock/income_statement/2012-06-30/issued_pdate_de_1.html" target="_self" class="incolor">中报速递</a></td>
              </tr>
            </table>
          </div>
          <!--<div class="HSpace-1-10"></div> -->
          <div class="Menu-Ti" id="navlf01"><img src="http://www.sinaimg.cn/cj/realstock/image2/finance_in_ws_010.gif" alt="" id="tImg1"/><span class="capname">指数资料</span></div>
    
          <div class="Menu-Con" id="item1" style="display:block;">
    
            <table cellspacing="0">
              <tr>
                <td>·<a href="/corp/go.php/vII_BasicInfo/indexid/000001.phtml" target="_self">基本属性</a></td>
                <td>·<a href="/corp/go.php/vII_NewestComponent/indexid/000001.phtml" target="_self">最新成分</a></td>
              </tr>
    
              <tr>
                <td>·<a href="/corp/go.php/vII_HistoryComponent/indexid/000001.phtml" target="_self">历史成分</a></td>
    
                <td>·<a href="http://biz.finance.sina.com.cn/hq/index.php?page=stock_list.php?index=000001" target="_self">指数成分行情</a></td>
              </tr>
              <tr>
                <td>·<a href="/corp/go.php/vII_BigIssue/indexid/000001.phtml" target="_self">大事记</a></td>
    
                <td>·<a href="/corp/go.php/vMS_MarketHistory/stockid/000001/type/S.phtml" target="_self">历史交易</a></td>
              </tr>
            </table>
          </div>
          <div class="Menu-Ti" id="navlf02"><img src="http://www.sinaimg.cn/cj/realstock/image2/finance_in_ws_010.gif" alt="" id="tImg2"/><span class="capname">选股工具</span></div>
          <div class="Menu-Con" id="item2" style="display:block;">
            <table cellspacing="0">
              <tr>
                <td>·<a href="http://vip.stock.finance.sina.com.cn/q/go.php/vIR_CustomSearch/index.phtml" target="_self">智能选股</a></td>
    
                <td>·<a href="http://biz.finance.sina.com.cn/browser/first.php" target="_self">数据浏览器</a></td>
              </tr>
    
              <tr> 
                <td colspan="2">·<a href="http://vip.stock.finance.sina.com.cn/moneyflow/" target="_self">主力揭秘</a></td>
              </tr>
            </table>
    
          </div>
    
          <!-- 菜单 end -->
    
        </div>
        <!-- 左侧 end -->
        <!-- 中间 begin -->
        <div id="center">
    
          <!-- 图 begin -->
          <div class="centerImgBlk">
            <!-- toolbartop begin -->
            <div class="toolbartop" id="toolbar">
    
              <div class="tbtb01">
                <h1 id="itemName"></h1>
                <h2><span id="itemMarket">-</span> 000001</h2>
    
              </div>
              <div class="tbtb02">
                <h3 id="itemCurrent" class="incolor">-</h3>
    
                <h4><span class="fRed01" id="itemdiffprice">-</span>&nbsp;&nbsp;<span class="fRed01" id="itemDiffpercent">-</span></h4>
                <h5 id="itemTickettime">-</h5>
              </div>
              <div class="tbtb03">
    
                <div class="tbtb0301">昨收盘:<span id="itemPrevious2">-</span> 今开盘:<span id="itemOpen2">-</span> 最高价:<span class="fRed01" id="itemHigh2">-</span> 最低价:<span class="fGreen01" id="itemLow2">-</span></div>
    
                <div class="tbtb0302">成交量:<span id="itemVolume2"></span>手 成交额:<span id="itemAmount2"></span> 指数振幅:<span id="itemRange"></span></div>
    
              </div>
    
        <!--new added-->
    
            <div class="sht">
                <div class="shtbipt">
                  <!--suggest begin--> 
                  <form method="post" id="f" name="iask_f" onSubmit="return S_Finance.constant._suggest(this)" action="http://biz.finance.sina.com.cn/suggest/lookup_n.php" target="_self"> 
                    <input type="hidden" name="s" value="1" /> 
                    <input type="hidden" name="portnum" id="portnum" value="8081" /> 
                    <input type="hidden" name="symbol" id="symbol" /> 
                    <input type="hidden" name="market" id="market" /> 
                    <input type="hidden" name="locadr" id="locadr" /> 
                    <input type="text" id="k" name="q" value="代码/名称/拼音" class="shtbipt01" maxlength="50" autocomplete="off"  onClick="javascript:if(this.value=='代码/名称/拼音')this.value='';" /><input type="submit" class="shtbipt02" value="查询" /><input type="button" class="shtbipt03" value="代码检索" onClick="window.open('http://finance.sina.com.cn/stock/lookup.shtml');" /> 
                  </form> 
                  <!--suggest end-->
    
                </div>
    
                <h1>
                    <a href="http://sina.allyes.com/main/adfclick?db=sina&bid=49278,76601,76666&cid=0,0,0&sid=72343&advid=2117&camid=11193&show=ignore&url=http://finance.sina.com.cn/focus/rwtzzl/index.shtml" target="_blank" class="icon1">个股免费咨询</a>  
                    <a href="http://comment4.news.sina.com.cn/comment/skin/feedback.html?channel=ly&newsid=177" target="_blank" class="icon2">公司资料意见反馈</a><!--<a href="bc.shtml" target="_self" class="icon3">旧版</a> --></h1>
              </div>
    
    
    
            </div>
            <!-- toolbartop end -->
    
    <!--<div style="margin-left: 0px; margin-top: 20px;">-->
    <div class="nav_menu" style="clear:both;">
    <ul class="Ti">
        <li class="menu0">指数资料:</li>
        <li class="menu02Off" id="m02-0"><a href="/corp/go.php/vII_BasicInfo/indexid/000001.phtml">基本属性</a></li>
        <li class="menu02Off" id="m02-1"><a href="/corp/go.php/vII_NewestComponent/indexid/000001.phtml">最新成分</a></li>
        <li class="menu02Off" id="m02-2"><a href="/corp/go.php/vII_HistoryComponent/indexid/000001.phtml">历史成分</a></li>
         <li class="menu02Off" id="m02-3"><a target='_blank'  href="http://biz.finance.sina.com.cn/hq/index.php?page=stock_list.php?index=000001">指数成分行情</a></li>
        <li class="menu02Off" id="m02-4"><a  href="/corp/go.php/vII_BigIssue/indexid/000001.phtml">大事记</a></li>
        <li class="menu02Off" id="m02-4"><a  href="/corp/go.php/vMS_MarketHistory/stockid/000001/type/S.phtml">历史交易</a></li>
     </ul>
    </div><div id="con02-4" class="tagmain">
      <!--历史交易begin-->
        <table width="100%" border="0" align="center" cellpadding="0" cellspacing="10" class="table2">
          <tr>
            <td  align="left" valign="top">
            <form method="get" name="daily" action="">
        <select name="year">
                        <option value="2015" selected>2015</option>
                        <option value="2014" >2014</option>
                        <option value="2013" >2013</option>
                        <option value="2012" >2012</option>
                        <option value="2011" >2011</option>
                        <option value="2010" >2010</option>
                        <option value="2009" >2009</option>
                        <option value="2008" >2008</option>
                        <option value="2007" >2007</option>
                        <option value="2006" >2006</option>
                        <option value="2005" >2005</option>
                        <option value="2004" >2004</option>
                        <option value="2003" >2003</option>
                        <option value="2002" >2002</option>
                        <option value="2001" >2001</option>
                        <option value="2000" >2000</option>
                        <option value="1999" >1999</option>
                        <option value="1998" >1998</option>
                        <option value="1997" >1997</option>
                        <option value="1996" >1996</option>
                        <option value="1995" >1995</option>
                        <option value="1994" >1994</option>
                        <option value="1993" >1993</option>
                        <option value="1992" >1992</option>
                        <option value="1991" >1991</option>
                        <option value="1990" >1990</option>
                </select>
        <select name="jidu">
                <option value="1" selected>一季度</option>
                <option value="2" >二季度</option>
                <option value="3" >三季度</option>
                <option value="4" >四季度</option>
            </select>
    
        <input type="submit" value="查询"> 
    </form>
    
            </td>
          </tr>
        </table>
    
            <table id="FundHoldSharesTable">
          <thead>
                <tr>
                    <th colspan="7">
                    上证综合指数(000001)<FONT COLOR="blue"></FONT><FONT COLOR="blue"></FONT>季度历史交易
                    </th>
                </tr>
          </thead>
          <tr class="tr_2">
            <td><div align="center"><strong>日期</strong></div></td>
            <td><div align="center"><strong>开盘价</strong></div></td>
            <td><div align="center"><strong>最高价</strong></div></td>
            <td><div align="center"><strong>收盘价</strong></div></td>
            <td class="tdr"><div align="center"><strong>最低价</strong></div></td>
            <td class="tdr"><div align="center"><strong>交易量(股)</strong></div></td>
            <td class="tdr"><div align="center"><strong>交易金额(元)</strong></div></td>
          </tr>
                  <tr >
                <td><div align="center">
                        <a target='_blank' href='http://vip.stock.finance.sina.com.cn/quotes_service/view/vMS_tradehistory.php?symbol=sh000001&date=2015-03-31'>
                2015-03-31          </a>
                            </div></td>
                <td><div align="center">3822.987</div></td>
                <td><div align="center">3835.567</div></td>
                <td><div align="center">3747.899</div></td>
                <td class="tdr"><div align="center">3737.043</div></td>
                <td class="tdr"><div align="center">56167603200</div></td>
                <td class="tdr"><div align="center">721294917632</div></td>
              </tr>
                      <tr class="tr_2">
                <td><div align="center">
                        <a target='_blank' href='http://vip.stock.finance.sina.com.cn/quotes_service/view/vMS_tradehistory.php?symbol=sh000001&date=2015-03-30'>
                2015-03-30          </a>
                            </div></td>
                <td><div align="center">3710.612</div></td>
                <td><div align="center">3795.935</div></td>
                <td><div align="center">3786.568</div></td>
                <td class="tdr"><div align="center">3710.612</div></td>
                <td class="tdr"><div align="center">56470233600</div></td>
                <td class="tdr"><div align="center">692125368320</div></td>
              </tr>
                      <tr >
                <td><div align="center">
                        <a target='_blank' href='http://vip.stock.finance.sina.com.cn/quotes_service/view/vMS_tradehistory.php?symbol=sh000001&date=2015-03-27'>
                2015-03-27          </a>
                            </div></td>
                <td><div align="center">3686.134</div></td>
                <td><div align="center">3710.477</div></td>
                <td><div align="center">3691.096</div></td>
                <td class="tdr"><div align="center">3656.831</div></td>
                <td class="tdr"><div align="center">40894515200</div></td>
                <td class="tdr"><div align="center">509298475008</div></td>
              </tr>
                      <tr class="tr_2">
                <td><div align="center">
                        <a target='_blank' href='http://vip.stock.finance.sina.com.cn/quotes_service/view/vMS_tradehistory.php?symbol=sh000001&date=2015-03-26'>
                2015-03-26          </a>
                            </div></td>
                <td><div align="center">3641.942</div></td>
                <td><div align="center">3707.318</div></td>
                <td><div align="center">3682.095</div></td>
                <td class="tdr"><div align="center">3615.011</div></td>
                <td class="tdr"><div align="center">48864720000</div></td>
                <td class="tdr"><div align="center">619515609088</div></td>
              </tr>
                      <tr >
                <td><div align="center">
                        <a target='_blank' href='http://vip.stock.finance.sina.com.cn/quotes_service/view/vMS_tradehistory.php?symbol=sh000001&date=2015-03-25'>
                2015-03-25          </a>
                            </div></td>
                <td><div align="center">3680.953</div></td>
                <td><div align="center">3693.151</div></td>
                <td><div align="center">3660.727</div></td>
                <td class="tdr"><div align="center">3634.559</div></td>
                <td class="tdr"><div align="center">52188633600</div></td>
                <td class="tdr"><div align="center">645498929152</div></td>
              </tr>
                      <tr class="tr_2">
                <td><div align="center">
                        <a target='_blank' href='http://vip.stock.finance.sina.com.cn/quotes_service/view/vMS_tradehistory.php?symbol=sh000001&date=2015-03-24'>
                2015-03-24          </a>
                            </div></td>
                <td><div align="center">3692.569</div></td>
                <td><div align="center">3715.873</div></td>
                <td><div align="center">3691.410</div></td>
                <td class="tdr"><div align="center">3600.698</div></td>
                <td class="tdr"><div align="center">63955468800</div></td>
                <td class="tdr"><div align="center">754884739072</div></td>
              </tr>
                      <tr >
                <td><div align="center">
                        <a target='_blank' href='http://vip.stock.finance.sina.com.cn/quotes_service/view/vMS_tradehistory.php?symbol=sh000001&date=2015-03-23'>
                2015-03-23          </a>
                            </div></td>
                <td><div align="center">3640.104</div></td>
                <td><div align="center">3688.249</div></td>
                <td><div align="center">3687.728</div></td>
                <td class="tdr"><div align="center">3635.485</div></td>
                <td class="tdr"><div align="center">53606284800</div></td>
                <td class="tdr"><div align="center">661574647808</div></td>
              </tr>
                      <tr class="tr_2">
                <td><div align="center">
                        <a target='_blank' href='http://vip.stock.finance.sina.com.cn/quotes_service/view/vMS_tradehistory.php?symbol=sh000001&date=2015-03-20'>
                2015-03-20          </a>
                            </div></td>
                <td><div align="center">3587.084</div></td>
                <td><div align="center">3632.338</div></td>
                <td><div align="center">3617.318</div></td>
                <td class="tdr"><div align="center">3569.380</div></td>
                <td class="tdr"><div align="center">51666166400</div></td>
                <td class="tdr"><div align="center">651771969536</div></td>
              </tr>
                      <tr >
                <td><div align="center">
                        <a target='_blank' href='http://vip.stock.finance.sina.com.cn/quotes_service/view/vMS_tradehistory.php?symbol=sh000001&date=2015-03-19'>
                2015-03-19          </a>
                            </div></td>
                <td><div align="center">3576.019</div></td>
                <td><div align="center">3600.684</div></td>
                <td><div align="center">3582.271</div></td>
                <td class="tdr"><div align="center">3546.844</div></td>
                <td class="tdr"><div align="center">53734662400</div></td>
                <td class="tdr"><div align="center">612249698304</div></td>
              </tr>
                      <tr class="tr_2">
                <td><div align="center">
                        <a target='_blank' href='http://vip.stock.finance.sina.com.cn/quotes_service/view/vMS_tradehistory.php?symbol=sh000001&date=2015-03-18'>
                2015-03-18          </a>
                            </div></td>
                <td><div align="center">3510.501</div></td>
                <td><div align="center">3577.662</div></td>
                <td><div align="center">3577.301</div></td>
                <td class="tdr"><div align="center">3503.853</div></td>
                <td class="tdr"><div align="center">54521715200</div></td>
                <td class="tdr"><div align="center">617367011328</div></td>
              </tr>
                      <tr >
                <td><div align="center">
                        <a target='_blank' href='http://vip.stock.finance.sina.com.cn/quotes_service/view/vMS_tradehistory.php?symbol=sh000001&date=2015-03-17'>
                2015-03-17          </a>
                            </div></td>
                <td><div align="center">3469.603</div></td>
                <td><div align="center">3504.123</div></td>
                <td><div align="center">3502.847</div></td>
                <td class="tdr"><div align="center">3459.694</div></td>
                <td class="tdr"><div align="center">52093952000</div></td>
                <td class="tdr"><div align="center">601500680192</div></td>
              </tr>
                      <tr class="tr_2">
                <td><div align="center">
                        <a target='_blank' href='http://vip.stock.finance.sina.com.cn/quotes_service/view/vMS_tradehistory.php?symbol=sh000001&date=2015-03-16'>
                2015-03-16          </a>
                            </div></td>
                <td><div align="center">3391.158</div></td>
                <td><div align="center">3449.305</div></td>
                <td><div align="center">3449.305</div></td>
                <td class="tdr"><div align="center">3377.087</div></td>
                <td class="tdr"><div align="center">39913241600</div></td>
                <td class="tdr"><div align="center">479355305984</div></td>
              </tr>
                      <tr >
                <td><div align="center">
                        <a target='_blank' href='http://vip.stock.finance.sina.com.cn/quotes_service/view/vMS_tradehistory.php?symbol=sh000001&date=2015-03-13'>
                2015-03-13          </a>
                            </div></td>
                <td><div align="center">3359.488</div></td>
                <td><div align="center">3391.255</div></td>
                <td><div align="center">3372.911</div></td>
                <td class="tdr"><div align="center">3352.150</div></td>
                <td class="tdr"><div align="center">32841014400</div></td>
                <td class="tdr"><div align="center">374041411584</div></td>
              </tr>
                      <tr class="tr_2">
                <td><div align="center">
                        <a target='_blank' href='http://vip.stock.finance.sina.com.cn/quotes_service/view/vMS_tradehistory.php?symbol=sh000001&date=2015-03-12'>
                2015-03-12          </a>
                            </div></td>
                <td><div align="center">3314.813</div></td>
                <td><div align="center">3360.054</div></td>
                <td><div align="center">3349.323</div></td>
                <td class="tdr"><div align="center">3300.488</div></td>
                <td class="tdr"><div align="center">35729510400</div></td>
                <td class="tdr"><div align="center">407192403968</div></td>
              </tr>
                      <tr >
                <td><div align="center">
                        <a target='_blank' href='http://vip.stock.finance.sina.com.cn/quotes_service/view/vMS_tradehistory.php?symbol=sh000001&date=2015-03-11'>
                2015-03-11          </a>
                            </div></td>
                <td><div align="center">3289.594</div></td>
                <td><div align="center">3325.054</div></td>
                <td><div align="center">3290.900</div></td>
                <td class="tdr"><div align="center">3278.471</div></td>
                <td class="tdr"><div align="center">28298553600</div></td>
                <td class="tdr"><div align="center">327573078016</div></td>
              </tr>
                      <tr class="tr_2">
                <td><div align="center">
                        <a target='_blank' href='http://vip.stock.finance.sina.com.cn/quotes_service/view/vMS_tradehistory.php?symbol=sh000001&date=2015-03-10'>
                2015-03-10          </a>
                            </div></td>
                <td><div align="center">3289.085</div></td>
                <td><div align="center">3309.915</div></td>
                <td><div align="center">3286.068</div></td>
                <td class="tdr"><div align="center">3277.095</div></td>
                <td class="tdr"><div align="center">28581756800</div></td>
                <td class="tdr"><div align="center">329955966976</div></td>
              </tr>
                      <tr >
                <td><div align="center">
                        <a target='_blank' href='http://vip.stock.finance.sina.com.cn/quotes_service/view/vMS_tradehistory.php?symbol=sh000001&date=2015-03-09'>
                2015-03-09          </a>
                            </div></td>
                <td><div align="center">3224.314</div></td>
                <td><div align="center">3307.702</div></td>
                <td><div align="center">3302.408</div></td>
                <td class="tdr"><div align="center">3198.370</div></td>
                <td class="tdr"><div align="center">32149542400</div></td>
                <td class="tdr"><div align="center">359927513088</div></td>
              </tr>
                      <tr class="tr_2">
                <td><div align="center">
                        <a target='_blank' href='http://vip.stock.finance.sina.com.cn/quotes_service/view/vMS_tradehistory.php?symbol=sh000001&date=2015-03-06'>
                2015-03-06          </a>
                            </div></td>
                <td><div align="center">3248.036</div></td>
                <td><div align="center">3266.933</div></td>
                <td><div align="center">3241.187</div></td>
                <td class="tdr"><div align="center">3234.533</div></td>
                <td class="tdr"><div align="center">28291577600</div></td>
                <td class="tdr"><div align="center">328344141824</div></td>
              </tr>
                      <tr >
                <td><div align="center">
                        <a target='_blank' href='http://vip.stock.finance.sina.com.cn/quotes_service/view/vMS_tradehistory.php?symbol=sh000001&date=2015-03-05'>
                2015-03-05          </a>
                            </div></td>
                <td><div align="center">3264.085</div></td>
                <td><div align="center">3266.638</div></td>
                <td><div align="center">3248.476</div></td>
                <td class="tdr"><div align="center">3221.666</div></td>
                <td class="tdr"><div align="center">32066358400</div></td>
                <td class="tdr"><div align="center">373580005376</div></td>
              </tr>
                      <tr class="tr_2">
                <td><div align="center">
                        <a target='_blank' href='http://vip.stock.finance.sina.com.cn/quotes_service/view/vMS_tradehistory.php?symbol=sh000001&date=2015-03-04'>
                2015-03-04          </a>
                            </div></td>
                <td><div align="center">3264.182</div></td>
                <td><div align="center">3286.588</div></td>
                <td><div align="center">3279.533</div></td>
                <td class="tdr"><div align="center">3250.484</div></td>
                <td class="tdr"><div align="center">29363952000</div></td>
                <td class="tdr"><div align="center">346789773312</div></td>
              </tr>
                      <tr >
                <td><div align="center">
                        <a target='_blank' href='http://vip.stock.finance.sina.com.cn/quotes_service/view/vMS_tradehistory.php?symbol=sh000001&date=2015-03-03'>
                2015-03-03          </a>
                            </div></td>
                <td><div align="center">3317.695</div></td>
                <td><div align="center">3317.695</div></td>
                <td><div align="center">3263.052</div></td>
                <td class="tdr"><div align="center">3260.429</div></td>
                <td class="tdr"><div align="center">38204460800</div></td>
                <td class="tdr"><div align="center">441593495552</div></td>
              </tr>
                      <tr class="tr_2">
                <td><div align="center">
                        <a target='_blank' href='http://vip.stock.finance.sina.com.cn/quotes_service/view/vMS_tradehistory.php?symbol=sh000001&date=2015-03-02'>
                2015-03-02          </a>
                            </div></td>
                <td><div align="center">3332.721</div></td>
                <td><div align="center">3336.760</div></td>
                <td><div align="center">3336.285</div></td>
                <td class="tdr"><div align="center">3298.669</div></td>
                <td class="tdr"><div align="center">34644566400</div></td>
                <td class="tdr"><div align="center">410259554304</div></td>
              </tr>
                      <tr >
                <td><div align="center">
                        <a target='_blank' href='http://vip.stock.finance.sina.com.cn/quotes_service/view/vMS_tradehistory.php?symbol=sh000001&date=2015-02-27'>
                2015-02-27          </a>
                            </div></td>
                <td><div align="center">3296.831</div></td>
                <td><div align="center">3324.546</div></td>
                <td><div align="center">3310.303</div></td>
                <td class="tdr"><div align="center">3291.007</div></td>
                <td class="tdr"><div align="center">29916371200</div></td>
                <td class="tdr"><div align="center">335019573248</div></td>
              </tr>
                      <tr class="tr_2">
                <td><div align="center">
                        <a target='_blank' href='http://vip.stock.finance.sina.com.cn/quotes_service/view/vMS_tradehistory.php?symbol=sh000001&date=2015-02-26'>
                2015-02-26          </a>
                            </div></td>
                <td><div align="center">3222.151</div></td>
                <td><div align="center">3300.616</div></td>
                <td><div align="center">3298.359</div></td>
                <td class="tdr"><div align="center">3202.188</div></td>
                <td class="tdr"><div align="center">30126387200</div></td>
                <td class="tdr"><div align="center">334347468800</div></td>
              </tr>
                      <tr >
                <td><div align="center">
                        <a target='_blank' href='http://vip.stock.finance.sina.com.cn/quotes_service/view/vMS_tradehistory.php?symbol=sh000001&date=2015-02-25'>
                2015-02-25          </a>
                            </div></td>
                <td><div align="center">3256.479</div></td>
                <td><div align="center">3257.223</div></td>
                <td><div align="center">3228.843</div></td>
                <td class="tdr"><div align="center">3215.552</div></td>
                <td class="tdr"><div align="center">23334809600</div></td>
                <td class="tdr"><div align="center">265143353344</div></td>
              </tr>
                      <tr class="tr_2">
                <td><div align="center">
                        <a target='_blank' href='http://vip.stock.finance.sina.com.cn/quotes_service/view/vMS_tradehistory.php?symbol=sh000001&date=2015-02-17'>
                2015-02-17          </a>
                            </div></td>
                <td><div align="center">3230.884</div></td>
                <td><div align="center">3255.725</div></td>
                <td><div align="center">3246.906</div></td>
                <td class="tdr"><div align="center">3230.772</div></td>
                <td class="tdr"><div align="center">22833262400</div></td>
                <td class="tdr"><div align="center">263340048384</div></td>
              </tr>
                      <tr >
                <td><div align="center">
                        <a target='_blank' href='http://vip.stock.finance.sina.com.cn/quotes_service/view/vMS_tradehistory.php?symbol=sh000001&date=2015-02-16'>
                2015-02-16          </a>
                            </div></td>
                <td><div align="center">3206.137</div></td>
                <td><div align="center">3228.846</div></td>
                <td><div align="center">3222.363</div></td>
                <td class="tdr"><div align="center">3195.884</div></td>
                <td class="tdr"><div align="center">22379742400</div></td>
                <td class="tdr"><div align="center">265950691328</div></td>
              </tr>
                      <tr class="tr_2">
                <td><div align="center">
                        <a target='_blank' href='http://vip.stock.finance.sina.com.cn/quotes_service/view/vMS_tradehistory.php?symbol=sh000001&date=2015-02-13'>
                2015-02-13          </a>
                            </div></td>
                <td><div align="center">3186.808</div></td>
                <td><div align="center">3237.159</div></td>
                <td><div align="center">3203.827</div></td>
                <td class="tdr"><div align="center">3182.794</div></td>
                <td class="tdr"><div align="center">26129043200</div></td>
                <td class="tdr"><div align="center">293017681920</div></td>
              </tr>
                      <tr >
                <td><div align="center">
                        <a target='_blank' href='http://vip.stock.finance.sina.com.cn/quotes_service/view/vMS_tradehistory.php?symbol=sh000001&date=2015-02-12'>
                2015-02-12          </a>
                            </div></td>
                <td><div align="center">3157.959</div></td>
                <td><div align="center">3181.766</div></td>
                <td><div align="center">3173.416</div></td>
                <td class="tdr"><div align="center">3134.244</div></td>
                <td class="tdr"><div align="center">19459230400</div></td>
                <td class="tdr"><div align="center">229691572224</div></td>
              </tr>
                      <tr class="tr_2">
                <td><div align="center">
                        <a target='_blank' href='http://vip.stock.finance.sina.com.cn/quotes_service/view/vMS_tradehistory.php?symbol=sh000001&date=2015-02-11'>
                2015-02-11          </a>
                            </div></td>
                <td><div align="center">3145.765</div></td>
                <td><div align="center">3166.421</div></td>
                <td><div align="center">3157.704</div></td>
                <td class="tdr"><div align="center">3139.052</div></td>
                <td class="tdr"><div align="center">17284009600</div></td>
                <td class="tdr"><div align="center">210862555136</div></td>
              </tr>
                      <tr >
                <td><div align="center">
                        <a target='_blank' href='http://vip.stock.finance.sina.com.cn/quotes_service/view/vMS_tradehistory.php?symbol=sh000001&date=2015-02-10'>
                2015-02-10          </a>
                            </div></td>
                <td><div align="center">3090.490</div></td>
                <td><div align="center">3142.099</div></td>
                <td><div align="center">3141.593</div></td>
                <td class="tdr"><div align="center">3084.253</div></td>
                <td class="tdr"><div align="center">19381713600</div></td>
                <td class="tdr"><div align="center">225084915712</div></td>
              </tr>
                      <tr class="tr_2">
                <td><div align="center">
                        <a target='_blank' href='http://vip.stock.finance.sina.com.cn/quotes_service/view/vMS_tradehistory.php?symbol=sh000001&date=2015-02-09'>
                2015-02-09          </a>
                            </div></td>
                <td><div align="center">3063.510</div></td>
                <td><div align="center">3119.034</div></td>
                <td><div align="center">3095.124</div></td>
                <td class="tdr"><div align="center">3049.111</div></td>
                <td class="tdr"><div align="center">20610838400</div></td>
                <td class="tdr"><div align="center">240719675392</div></td>
              </tr>
                      <tr >
                <td><div align="center">
                        <a target='_blank' href='http://vip.stock.finance.sina.com.cn/quotes_service/view/vMS_tradehistory.php?symbol=sh000001&date=2015-02-06'>
                2015-02-06          </a>
                            </div></td>
                <td><div align="center">3120.090</div></td>
                <td><div align="center">3129.539</div></td>
                <td><div align="center">3075.907</div></td>
                <td class="tdr"><div align="center">3052.939</div></td>
                <td class="tdr"><div align="center">24674966400</div></td>
                <td class="tdr"><div align="center">266502782976</div></td>
              </tr>
                      <tr class="tr_2">
                <td><div align="center">
                        <a target='_blank' href='http://vip.stock.finance.sina.com.cn/quotes_service/view/vMS_tradehistory.php?symbol=sh000001&date=2015-02-05'>
                2015-02-05          </a>
                            </div></td>
                <td><div align="center">3251.212</div></td>
                <td><div align="center">3251.212</div></td>
                <td><div align="center">3136.531</div></td>
                <td class="tdr"><div align="center">3135.819</div></td>
                <td class="tdr"><div align="center">30613929600</div></td>
                <td class="tdr"><div align="center">348266954752</div></td>
              </tr>
                      <tr >
                <td><div align="center">
                        <a target='_blank' href='http://vip.stock.finance.sina.com.cn/quotes_service/view/vMS_tradehistory.php?symbol=sh000001&date=2015-02-04'>
                2015-02-04          </a>
                            </div></td>
                <td><div align="center">3212.822</div></td>
                <td><div align="center">3238.982</div></td>
                <td><div align="center">3174.126</div></td>
                <td class="tdr"><div align="center">3171.144</div></td>
                <td class="tdr"><div align="center">24909808000</div></td>
                <td class="tdr"><div align="center">290155167744</div></td>
              </tr>
                      <tr class="tr_2">
                <td><div align="center">
                        <a target='_blank' href='http://vip.stock.finance.sina.com.cn/quotes_service/view/vMS_tradehistory.php?symbol=sh000001&date=2015-02-03'>
                2015-02-03          </a>
                            </div></td>
                <td><div align="center">3156.086</div></td>
                <td><div align="center">3207.935</div></td>
                <td><div align="center">3204.907</div></td>
                <td class="tdr"><div align="center">3129.732</div></td>
                <td class="tdr"><div align="center">24819216000</div></td>
                <td class="tdr"><div align="center">283355938816</div></td>
              </tr>
                      <tr >
                <td><div align="center">
                        <a target='_blank' href='http://vip.stock.finance.sina.com.cn/quotes_service/view/vMS_tradehistory.php?symbol=sh000001&date=2015-02-02'>
                2015-02-02          </a>
                            </div></td>
                <td><div align="center">3148.136</div></td>
                <td><div align="center">3175.134</div></td>
                <td><div align="center">3128.300</div></td>
                <td class="tdr"><div align="center">3122.572</div></td>
                <td class="tdr"><div align="center">25086163200</div></td>
                <td class="tdr"><div align="center">266849959936</div></td>
              </tr>
                      <tr class="tr_2">
                <td><div align="center">
                        <a target='_blank' href='http://vip.stock.finance.sina.com.cn/quotes_service/view/vMS_tradehistory.php?symbol=sh000001&date=2015-01-30'>
                2015-01-30          </a>
                            </div></td>
                <td><div align="center">3273.747</div></td>
                <td><div align="center">3288.503</div></td>
                <td><div align="center">3210.363</div></td>
                <td class="tdr"><div align="center">3210.308</div></td>
                <td class="tdr"><div align="center">25831254400</div></td>
                <td class="tdr"><div align="center">284265644032</div></td>
              </tr>
                      <tr >
                <td><div align="center">
                        <a target='_blank' href='http://vip.stock.finance.sina.com.cn/quotes_service/view/vMS_tradehistory.php?symbol=sh000001&date=2015-01-29'>
                2015-01-29          </a>
                            </div></td>
                <td><div align="center">3258.997</div></td>
                <td><div align="center">3286.786</div></td>
                <td><div align="center">3262.305</div></td>
                <td class="tdr"><div align="center">3234.241</div></td>
                <td class="tdr"><div align="center">27465862400</div></td>
                <td class="tdr"><div align="center">296424505344</div></td>
              </tr>
                      <tr class="tr_2">
                <td><div align="center">
                        <a target='_blank' href='http://vip.stock.finance.sina.com.cn/quotes_service/view/vMS_tradehistory.php?symbol=sh000001&date=2015-01-28'>
                2015-01-28          </a>
                            </div></td>
                <td><div align="center">3325.722</div></td>
                <td><div align="center">3354.802</div></td>
                <td><div align="center">3305.738</div></td>
                <td class="tdr"><div align="center">3294.655</div></td>
                <td class="tdr"><div align="center">30192710400</div></td>
                <td class="tdr"><div align="center">341564293120</div></td>
              </tr>
                      <tr >
                <td><div align="center">
                        <a target='_blank' href='http://vip.stock.finance.sina.com.cn/quotes_service/view/vMS_tradehistory.php?symbol=sh000001&date=2015-01-27'>
                2015-01-27          </a>
                            </div></td>
                <td><div align="center">3389.853</div></td>
                <td><div align="center">3390.216</div></td>
                <td><div align="center">3352.960</div></td>
                <td class="tdr"><div align="center">3290.219</div></td>
                <td class="tdr"><div align="center">37451753600</div></td>
                <td class="tdr"><div align="center">418298855424</div></td>
              </tr>
                      <tr class="tr_2">
                <td><div align="center">
                        <a target='_blank' href='http://vip.stock.finance.sina.com.cn/quotes_service/view/vMS_tradehistory.php?symbol=sh000001&date=2015-01-26'>
                2015-01-26          </a>
                            </div></td>
                <td><div align="center">3347.257</div></td>
                <td><div align="center">3384.798</div></td>
                <td><div align="center">3383.182</div></td>
                <td class="tdr"><div align="center">3321.315</div></td>
                <td class="tdr"><div align="center">31754099200</div></td>
                <td class="tdr"><div align="center">358427459584</div></td>
              </tr>
                      <tr >
                <td><div align="center">
                        <a target='_blank' href='http://vip.stock.finance.sina.com.cn/quotes_service/view/vMS_tradehistory.php?symbol=sh000001&date=2015-01-23'>
                2015-01-23          </a>
                            </div></td>
                <td><div align="center">3357.096</div></td>
                <td><div align="center">3406.786</div></td>
                <td><div align="center">3351.764</div></td>
                <td class="tdr"><div align="center">3328.293</div></td>
                <td class="tdr"><div align="center">36624924800</div></td>
                <td class="tdr"><div align="center">420979539968</div></td>
              </tr>
                      <tr class="tr_2">
                <td><div align="center">
                        <a target='_blank' href='http://vip.stock.finance.sina.com.cn/quotes_service/view/vMS_tradehistory.php?symbol=sh000001&date=2015-01-22'>
                2015-01-22          </a>
                            </div></td>
                <td><div align="center">3327.319</div></td>
                <td><div align="center">3352.384</div></td>
                <td><div align="center">3343.344</div></td>
                <td class="tdr"><div align="center">3293.978</div></td>
                <td class="tdr"><div align="center">35338297600</div></td>
                <td class="tdr"><div align="center">407874076672</div></td>
              </tr>
                      <tr >
                <td><div align="center">
                        <a target='_blank' href='http://vip.stock.finance.sina.com.cn/quotes_service/view/vMS_tradehistory.php?symbol=sh000001&date=2015-01-21'>
                2015-01-21          </a>
                            </div></td>
                <td><div align="center">3189.085</div></td>
                <td><div align="center">3337.004</div></td>
                <td><div align="center">3323.611</div></td>
                <td class="tdr"><div align="center">3178.343</div></td>
                <td class="tdr"><div align="center">41095603200</div></td>
                <td class="tdr"><div align="center">473758662656</div></td>
              </tr>
                      <tr class="tr_2">
                <td><div align="center">
                        <a target='_blank' href='http://vip.stock.finance.sina.com.cn/quotes_service/view/vMS_tradehistory.php?symbol=sh000001&date=2015-01-20'>
                2015-01-20          </a>
                            </div></td>
                <td><div align="center">3114.560</div></td>
                <td><div align="center">3190.245</div></td>
                <td><div align="center">3173.052</div></td>
                <td class="tdr"><div align="center">3100.477</div></td>
                <td class="tdr"><div align="center">35708080000</div></td>
                <td class="tdr"><div align="center">416295223296</div></td>
              </tr>
                      <tr >
                <td><div align="center">
                        <a target='_blank' href='http://vip.stock.finance.sina.com.cn/quotes_service/view/vMS_tradehistory.php?symbol=sh000001&date=2015-01-19'>
                2015-01-19          </a>
                            </div></td>
                <td><div align="center">3189.727</div></td>
                <td><div align="center">3262.207</div></td>
                <td><div align="center">3116.351</div></td>
                <td class="tdr"><div align="center">3095.066</div></td>
                <td class="tdr"><div align="center">40109878400</div></td>
                <td class="tdr"><div align="center">409885999104</div></td>
              </tr>
                      <tr class="tr_2">
                <td><div align="center">
                        <a target='_blank' href='http://vip.stock.finance.sina.com.cn/quotes_service/view/vMS_tradehistory.php?symbol=sh000001&date=2015-01-16'>
                2015-01-16          </a>
                            </div></td>
                <td><div align="center">3343.603</div></td>
                <td><div align="center">3400.318</div></td>
                <td><div align="center">3376.495</div></td>
                <td class="tdr"><div align="center">3340.490</div></td>
                <td class="tdr"><div align="center">33987676800</div></td>
                <td class="tdr"><div align="center">392253898752</div></td>
              </tr>
                      <tr >
                <td><div align="center">
                        <a target='_blank' href='http://vip.stock.finance.sina.com.cn/quotes_service/view/vMS_tradehistory.php?symbol=sh000001&date=2015-01-15'>
                2015-01-15          </a>
                            </div></td>
                <td><div align="center">3224.070</div></td>
                <td><div align="center">3337.084</div></td>
                <td><div align="center">3336.455</div></td>
                <td class="tdr"><div align="center">3207.545</div></td>
                <td class="tdr"><div align="center">28254624000</div></td>
                <td class="tdr"><div align="center">330610540544</div></td>
              </tr>
                      <tr class="tr_2">
                <td><div align="center">
                        <a target='_blank' href='http://vip.stock.finance.sina.com.cn/quotes_service/view/vMS_tradehistory.php?symbol=sh000001&date=2015-01-14'>
                2015-01-14          </a>
                            </div></td>
                <td><div align="center">3242.337</div></td>
                <td><div align="center">3268.483</div></td>
                <td><div align="center">3222.437</div></td>
                <td class="tdr"><div align="center">3193.978</div></td>
                <td class="tdr"><div align="center">24019075200</div></td>
                <td class="tdr"><div align="center">267204526080</div></td>
              </tr>
                      <tr >
                <td><div align="center">
                        <a target='_blank' href='http://vip.stock.finance.sina.com.cn/quotes_service/view/vMS_tradehistory.php?symbol=sh000001&date=2015-01-13'>
                2015-01-13          </a>
                            </div></td>
                <td><div align="center">3223.542</div></td>
                <td><div align="center">3259.386</div></td>
                <td><div align="center">3235.301</div></td>
                <td class="tdr"><div align="center">3214.412</div></td>
                <td class="tdr"><div align="center">23072576000</div></td>
                <td class="tdr"><div align="center">273588781056</div></td>
              </tr>
                      <tr class="tr_2">
                <td><div align="center">
                        <a target='_blank' href='http://vip.stock.finance.sina.com.cn/quotes_service/view/vMS_tradehistory.php?symbol=sh000001&date=2015-01-12'>
                2015-01-12          </a>
                            </div></td>
                <td><div align="center">3258.213</div></td>
                <td><div align="center">3275.185</div></td>
                <td><div align="center">3229.316</div></td>
                <td class="tdr"><div align="center">3191.582</div></td>
                <td class="tdr"><div align="center">32206467200</div></td>
                <td class="tdr"><div align="center">366273069056</div></td>
              </tr>
                      <tr >
                <td><div align="center">
                        <a target='_blank' href='http://vip.stock.finance.sina.com.cn/quotes_service/view/vMS_tradehistory.php?symbol=sh000001&date=2015-01-09'>
                2015-01-09          </a>
                            </div></td>
                <td><div align="center">3276.965</div></td>
                <td><div align="center">3404.834</div></td>
                <td><div align="center">3285.412</div></td>
                <td class="tdr"><div align="center">3267.509</div></td>
                <td class="tdr"><div align="center">41024086400</div></td>
                <td class="tdr"><div align="center">458648027136</div></td>
              </tr>
                      <tr class="tr_2">
                <td><div align="center">
                        <a target='_blank' href='http://vip.stock.finance.sina.com.cn/quotes_service/view/vMS_tradehistory.php?symbol=sh000001&date=2015-01-08'>
                2015-01-08          </a>
                            </div></td>
                <td><div align="center">3371.957</div></td>
                <td><div align="center">3381.566</div></td>
                <td><div align="center">3293.456</div></td>
                <td class="tdr"><div align="center">3285.095</div></td>
                <td class="tdr"><div align="center">37113116800</div></td>
                <td class="tdr"><div align="center">399230304256</div></td>
              </tr>
                      <tr >
                <td><div align="center">
                        <a target='_blank' href='http://vip.stock.finance.sina.com.cn/quotes_service/view/vMS_tradehistory.php?symbol=sh000001&date=2015-01-07'>
                2015-01-07          </a>
                            </div></td>
                <td><div align="center">3326.649</div></td>
                <td><div align="center">3374.896</div></td>
                <td><div align="center">3373.954</div></td>
                <td class="tdr"><div align="center">3312.211</div></td>
                <td class="tdr"><div align="center">39191888000</div></td>
                <td class="tdr"><div align="center">436416708608</div></td>
              </tr>
                      <tr class="tr_2">
                <td><div align="center">
                        <a target='_blank' href='http://vip.stock.finance.sina.com.cn/quotes_service/view/vMS_tradehistory.php?symbol=sh000001&date=2015-01-06'>
                2015-01-06          </a>
                            </div></td>
                <td><div align="center">3330.799</div></td>
                <td><div align="center">3394.224</div></td>
                <td><div align="center">3351.446</div></td>
                <td class="tdr"><div align="center">3303.184</div></td>
                <td class="tdr"><div align="center">50166169600</div></td>
                <td class="tdr"><div align="center">532398473216</div></td>
              </tr>
                      <tr >
                <td><div align="center">
                        <a target='_blank' href='http://vip.stock.finance.sina.com.cn/quotes_service/view/vMS_tradehistory.php?symbol=sh000001&date=2015-01-05'>
                2015-01-05          </a>
                            </div></td>
                <td><div align="center">3258.627</div></td>
                <td><div align="center">3369.281</div></td>
                <td><div align="center">3350.519</div></td>
                <td class="tdr"><div align="center">3253.883</div></td>
                <td class="tdr"><div align="center">53135238400</div></td>
                <td class="tdr"><div align="center">549760073728</div></td>
              </tr>
    
          </table>
          </div>
            <script language="javascript" type="text/javascript">
                romanceTables(["FundHoldSharesTable"]);
            </script>
      <!--历史交易end-->
          </div>
    
    <!-- 用来解决整个wrap高度显示的问题 -->      
    <style type="text/css">
    #wrap{overflow:hidden;}
    </style>
    
    <!--</div>-->
    <div class="clearit"></div>
          </div>
    
        </div>
        <!-- 中间 end -->
    
      </div>
    </div>
    
    
    <!-- 首页标准尾_START -->
    
    <style type="text/css">
    #footer{width:950px; text-align:center; line-height:21px; font-size:12px;margin-top:20px;color:#333;margin-left:auto;margin-right:auto;}
    #footer a:link{color:#000099}
    #footer a:visited{color:#800080}
    #footer a:hover{color:#ff0000;text-decoration:underline;}
    #footer a:active {color:#0100A3; text-decoration:none;}
    </style>
    <!-- SUDA_CODE_START --> 
    <script type="text/javascript" src="http://www.sinaimg.cn/unipro/pub/suda_s_v851c.js"></script> 
    <script type="text/javascript" > 
    _S_pSt(_S_PID_); 
    </script> 
    <noScript> 
    <div style='position:absolute;top:0;left:0;width:0;height:0;visibility:hidden'><img width=0 height=0 src='http://beacon.sina.com.cn/a.gif?noScript' border='0' alt='' /></div> 
    </noScript> 
    <!-- SUDA_CODE_END --> 
    
    <!-- Start  Wrating  -->
    <script language="javascript">
    var wrUrl="//sina.wrating.com/";var wrDomain="sina.com.cn";var wratingDefaultAcc="860010-0323010000";var wratingAccArray={"torch.2008.sina.com.cn":"860010-0308070000","video.sina.com.cn":"860010-0309010000","cctv.sina.com.cn":"860010-0309020000","chat.sina.com.cn":"860010-0311010000","ent.sina.com.cn":"860010-0312010000","tech.sina.com.cn":"860010-0313010000","mobile.sina.com.cn":"860010-0313020000","house.sina.com.cn":"860010-0315010000","bj.house.sina.com.cn":"860010-0315020000","auto.sina.com.cn":"860010-0316010000","eladies.sina.com.cn":"860010-0317010000","bj.sina.com.cn":"860010-0317020000","woman.sina.com.cn":"860010-0317010000","women.sina.com.cn":"860010-0317010000","lady.sina.com.cn":"860010-0317010000","man.eladies.sina.com.cn":"860010-0317030000","games.sina.com.cn":"860010-0318010000","game.sina.com.cn":"860010-0318010000","edu.sina.com.cn":"860010-0307010000","baby.sina.com.cn":"860010-0320010000","kid.sina.com.cn":"860010-0320020000","astro.sina.com.cn":"860010-0321020000","news.sina.com.cn":"860010-0310010000","weather.news.sina.com.cn":"860010-0310020000","mil.news.sina.com.cn":"860010-0310030000","www.sina.com.cn":"860010-0322010000","home.sina.com.cn":"860010-0322010000","sports.sina.com.cn":"860010-0308010000","shidefc.sina.com.cn":"860010-0308020000","weiqi.sina.com.cn":"860010-0308030000","f1.sina.com.cn":"860010-0308040000","golf.sina.com.cn":"860010-0308050000","2002.sina.com.cn":"860010-0308060000","2004.sina.com.cn":"860010-0308060000","2006.sina.com.cn":"860010-0308060000","2008.sina.com.cn":"860010-0308070000","yayun2002.sina.com.cn":"860010-0308060000","yayun2006.sina.com.cn":"860010-0308060000","inter.sina.com.cn":"860010-0308080000","chelsea.sina.com.cn":"860010-0308090000","book.sina.com.cn":"860010-0319010000","cul.book.sina.com.cn":"860010-0319020000","comic.book.sina.com.cn":"860010-0319030000","finance.sina.com.cn":"860010-0314010000","money.sina.com.cn":"860010-0314020000","yue.sina.com.cn":"860010-0324010000","www.sina.com":"860010-0322010000"};function vjTrack(){var U=1800;var T=false;var S=false;var R="";var Q="0";var P="";var N;var L;var K;var J;var I;var H="expires=Fri, 1 Jan 2038 00:00:00 GMT;";var G=0;if(document.location.protocol=="file:"){return }T=navigator.cookieEnabled?"1":"0";S=navigator.javaEnabled()?"1":"0";var F="0";var E;var C=-1;var D=document.cookie;if(T=="1"){C=D.indexOf("vjuids=");if(C<0){E=vjVisitorID();document.cookie="vjuids="+escape(E)+";"+H+";domain="+wrDomain+";path=/;";if(document.cookie.indexOf("vjuids=")<0){T="0"}else{Q="1"}}else{E=vjGetCookie("vjuids")}}L=document.referrer;if(!L||L==""){L=""}R=vjFlash();if(self.screen){N=screen.width+"x"+screen.height+"x"+screen.colorDepth}else{if(self.java){var M=java.awt.Toolkit.getDefaultToolkit();var O=M.getScreenSize();N=O.width+"x"+O.height+"x0"}}if(navigator.language){K=navigator.language.toLowerCase()}else{if(navigator.browserLanguage){K=navigator.browserLanguage.toLowerCase()}else{K="-"}}I="";var B;var X;X=new Date();J=X.getTimezoneOffset()/-60;J=X.getTimezoneOffset()/-60;B="&s="+N+"&l="+K+"&z="+J+"&j="+S+"&f="+R;if(T=="1"){C=document.cookie.indexOf("vjlast=");if(C<0){G=0}else{G=parseInt(vjGetCookie("vjlast"))}}if((X.getTime()/1000)-G>U){F="1";document.cookie="vjlast="+Math.round(X.getTime()/1000)+";"+H+";domain="+wrDomain+";path=/;"}if(L!=""){B=B+"&r="+escape(L)}if(F!="0"){B=B+"&n="+G}if(Q!="0"){B=B+"&u="+Q}var V;var A=vjGetAcc();var W=vjGetDomain();V=wrUrl+"a.gif?a="+X.getTime().toString(16)+"&t="+escape(I)+"&i="+escape(E)+"&b="+escape(document.location)+"&c="+A+B+"&ck="+W;document.write('<img src="'+V+'" width="1" height="1" />')}function vjGetAcc(){var B=document.location.toString().toLowerCase();var C=(B.split("/"))[2];var A=wratingAccArray[C];if(typeof (A)=="undefined"){A=wratingDefaultAcc}return A}function vjFlash(){var _wr_f="-",_wr_n=navigator;if(_wr_n.plugins&&_wr_n.plugins.length){for(var ii=0;ii<_wr_n.plugins.length;ii++){if(_wr_n.plugins[ii].name.indexOf("Shockwave Flash")!=-1){_wr_f=_wr_n.plugins[ii].description.split("Shockwave Flash ")[1];break}}}else{if(window.ActiveXObject){for(var ii=10;ii>=2;ii--){try{var fl=eval("new ActiveXObject('ShockwaveFlash.ShockwaveFlash."+ii+"');");if(fl){_wr_f=ii+".0";break}}catch(e){}}}}return _wr_f}function vjHash(B){if(!B||B==""){return 0}var D=0;for(var C=B.length-1;C>=0;C--){var A=parseInt(B.charCodeAt(C));D=(D<<5)+D+A}return D}function vjVisitorID(){var B=vjHash(document.location+document.cookie+document.referrer).toString(16);var A;A=new Date();return B+"."+A.getTime().toString(16)+"."+Math.random().toString(16)}function vjGetCookieVal(B){var A=document.cookie.indexOf(";",B);if(A==-1){A=document.cookie.length}return unescape(document.cookie.substring(B,A))}function vjGetCookie(C){var B=C+"=";var F=B.length;var A=document.cookie.length;var E=0;while(E<A){var D=E+F;if(document.cookie.substring(E,D)==B){return vjGetCookieVal(D)}E=document.cookie.indexOf(" ",E)+1;if(E==0){break}}return null}function vjGetDomain(){var A=0;try{if(window.self.parent!=self){var D=/sina.com/i;var C=document.location.toString().toLowerCase();var B=parent.location.toString().toLowerCase();if(D.test(C)&&D.test(B)){A=1}}}catch(e){A=1}return A}vjTrack();
    </script>
    <!-- End Wrating-->
    
    <div id="footer">
    客户服务热线:4006900000  
    欢迎批评指正<br>
    
    <a target="_blank" href="http://tech.sina.com.cn/focus/sinahelp.shtml">常见问题解答</a>  
    <a target="_blank" href="http://net.china.cn/chinese/index.htm">互联网违法和不良信息举报</a> 
    <a target="_blank" href="http://comment5.news.sina.com.cn/comment/skin/feedback.html?channel=ly&amp;newsid=5">新浪财经意见反馈留言板</a>
    <br><br>
    <a href="http://corp.sina.com.cn/chn/">新浪简介</a> | <a href="http://corp.sina.com.cn/eng/">About Sina</a> | <a href="http://emarketing.sina.com.cn/">广告服务</a> | <a href="http://www.sina.com.cn/contactus.html">联系我们</a> | <a href="http://corp.sina.com.cn/chn/sina_job.html">招聘信息</a> | <a href="http://www.sina.com.cn/intro/lawfirm.shtml">网站律师</a> | <a href="http://english.sina.com">SINA English</a> | <a href="http://members.sina.com.cn/apply/">通行证注册</a> | <a href="http://help.sina.com.cn/">产品答疑</a><br><br>Copyright &copy; 1996-2015 SINA Corporation, All Rights Reserved<br><br>新浪公司 <a target="_blank" href="http://www.sina.com.cn/intro/copyright.shtml">版权所有</a>
    </div>
    
    <!-- 首页标准尾_END -->
    
    <!-- suggest -->
    <script type="text/javascript" src="http://finance.sina.com.cn/iframe/nza_self.js"></script> 
    <script type="text/javascript" id="recscript"></script>
    
    <script language="javascript" type="text/javascript">
    <!--//--><![CDATA[//><!--
    /* 整个页面js开始运 */
    //var App = new S_Finance.App(fullcode);
    try{var App = new S_Finance.App(fullcode);}catch(er){}
    //--><!]]>
    </script>
    
    <!-- START WRating v1.0 -->
    <div style="display:none">
    <script type="text/javascript" src="http://sina.wrating.com/a1.js"></script>
    <script type="text/javascript">
    var vjAcc="860010-0326010000";
    var wrUrl="http://sina.wrating.com/";
    vjTrack();
    </script>
    <noscript><img src="http://sina.wrating.com/a.gif?c=860010-0326010000" width="1" height="1"/></noscript>
    </div>
    <!-- END WRating v1.0 -->
    <!-- SUDA_CODE_START --> 
    <script type="text/javascript" src="http://www.sinaimg.cn/unipro/pub/suda_s_v839c.js"></script> 
    <script type="text/javascript" > 
    _S_pSt(_S_PID_); 
    </script> 
    <!-- SUDA_CODE_END -->
    </body>
    </html>
    
    
    


    • 复制和黏贴到记事本里,静静地思考和琢磨如何才能通过正则匹配获取到你想要的信息。

    • 通过修改我的程序代码,从不同的渠道和网页抓取你想要的数据。等熟悉了以后,就可以自己写抓包代码啦。

    展开全文
  • 13行MATLAB代码实现网络爬虫 爬取NASA画廊星图 更新于:​2021/04/18​ 源代码 N = input('Input the number you want to download:'); URL = 'https://www.nasa.gov/api/2/ubernode/_search'; mainURL = '...

    13行MATLAB代码实现网络爬虫 爬取NASA画廊星图


    2021/04/18​上传

    2021/04/21更新:修改N的输入方式,增加对png格式图片的下载支持,增加了自动处理几种错误情况的代码,能够将下载过程与报错记录保存到日志中。

    源代码

    N = input('Input the number you want to download:');
        URL = 'https://www.nasa.gov/api/2/ubernode/_search';
    mainURL = 'https://www.nasa.gov/sites/default/files/';
    opt = weboptions('Timeout',10);
    for i=1:N
        data = webread(URL,'size',num2str(N),'from','0','sort','promo-date-time:desc','q','((ubernode-type:image) AND (routes:1446))','_source_include','promo-date-time,master-image,nid,title,topics,missions,collections,other-tags,ubernode-type,primary-tag,secondary-tag,cardfeed-title,type,collection-asset-link,link-or-attachment,pr-leader-sentence,image-feature-caption,attachments,uri',opt);
        imgURL = append(mainURL,data.hits.hits(i).x_source.master_image.uri(10:end));
        img = webread(imgURL,opt);
        filename = append('Img_',num2str(i),'_',data.hits.hits(i).x_source.master_image.title,'.jpg');
    	imwrite(img,filename);
        disp(append('FINISHED:',num2str(i),'/',num2str(N)));
    end
    disp('Completed!');
    

    使用方法

    .m脚本文件所在路径添加到MATLAB路径中,运行脚本,命令行提示:Input the number you want to download:,输入你想下载的图片数量后,爬虫自动开始运行并显示进度,进度读完则显示Completed!,图片保存在脚本所在目录下。

    讲解

    本爬虫仅适用于爬取NASA画廊每日图片,但只要取得了图片链接,用此方法可以爬取其他更多网站。

    https://www.nasa.gov/multimedia/imagegallery/iotd.html使用F12中Network工具,可以抓取到网页获取图片信息的网址接口URL,它的参数由几个部分组成,其中size对应一次获取的图片数量,则可通过变更size来获得不同的图片数量。

    URL的响应中,包含我们要获取的图片链接的一部分,即uri

    通过mainURLuri(10:end)组合可以得到不同编号的图片链接,使用webread()函数读入即可。

    weboption()函数用于设置访问方式为Get与超时响应时间Timeout

    append()合并字符串,imwrite()将图片写入指定文件并重命名。

    via nasa.gov


    2021/04/21更新:修改N的输入方式,增加对png格式图片的下载,增加了自动处理几种错误情况的代码,能够将下载过程与报错记录保存到日志中。

    2021/04/21源代码:

    disp('Input the number you want to download:[N1-N2]');
    N1 = input('N1:');
    N2 = input('N2:');
    disp(append('From ',num2str(min(N1,N2)),' to ',num2str(max(N1,N2)),' There are ',num2str(max(N1,N2)-min(N1,N2)+1),' pictures.'));
    URL = 'https://www.nasa.gov/api/2/ubernode/_search';
    mainURL = 'https://www.nasa.gov/sites/default/files/';
    opt = weboptions('Timeout',10);
    ispng=1;
    path = 'F:\PictureDownload\PictureDownload';
    for i=min(N1,N2):max(N1,N2)
        try
            data = webread(URL,'size',num2str(i),'from','0','sort','promo-date-time:desc','q','((ubernode-type:image) AND (routes:1446))','_source_include','promo-date-time,master-image,nid,title,topics,missions,collections,other-tags,ubernode-type,primary-tag,secondary-tag,cardfeed-title,type,collection-asset-link,link-or-attachment,pr-leader-sentence,image-feature-caption,attachments,uri',opt);
        catch
            disp('[ERROR]Failed to connect to the website. Check your web connection.');
            break
        end
        imgURL = append(mainURL,data.hits.hits(i).x_source.master_image.uri(10:end));
        try
            img = webread(imgURL,opt);
        catch
            disp(append('[WARN]Failed to download the ',num2str(i),'th picture. It has been skipped up.'));
            disp(append('[LINK]',imgURL));
            i = i+1;
            continue
        end
        filename = append(path,'Img_',num2str(i),'_',data.hits.hits(i).x_source.master_image.title,'.jpg');
        try
            imwrite(img,filename);
            disp(append('[',num2str(i),']FINISHED:',num2str(i-min(N1,N2)+1),'/',num2str(max(N1,N2)-min(N1,N2)+1)));
        catch
            filename = append(path,'Img_',num2str(i),'_',data.hits.hits(i).x_source.master_image.title,'.png');
            try
                imwrite(img,filename);
            catch
                ispng=0;
            end
            if ispng==1
                disp(append('[WARN]The ',num2str(i),'th picture is the format of png, it has been download successfully.'))
            else
                disp(append('[WARN]Failed to write in img file, The No.',num2str(i),' picture has been skipped up.'));
                disp(append('[LINK]:',imgURL));
                i = i+1;
            end
        end
    end
    disp('Completed!');
    
    展开全文
  • MATLAB爬虫爬取股票数据

    千次阅读 2019-09-28 01:32:26
    近年来,大数据盛行,有关爬虫的教程层次不穷。那么,爬虫到底是什么呢? 什么是爬虫? 百度百科是这样定义的: 网络爬虫(又被称为网页蜘蛛,网络机器人,在FOAF社区中间,更经常的称为网页追逐者),是一种按照...

    matlab1389ca169df5ca1d.png

    近年来,大数据盛行,有关爬虫的教程层次不穷。那么,爬虫到底是什么呢?

    什么是爬虫?

    百度百科是这样定义的:

    网络爬虫(又被称为网页蜘蛛,网络机器人,在FOAF社区中间,更经常的称为网页追逐者),是一种按照一定的规则,自动地抓取万维网信息的程序或者脚本。另外一些不常使用的名字还有蚂蚁、自动索引、模拟程序或者蠕虫更多解释

    就我个人理解,所谓的爬虫,就是代替人工复制粘贴去获取网络资源。平常我们需要批量下载图片、下载表格数据时,在没有爬虫的帮助下,只能借助CTRL+C 、CTRL+V 了,非常的繁琐,还容易出错。但是,你会发现,这些资源呈现出来,都是经过整理的。图片的链接是有规律的字符串,数据的网页源码是有规律的标签包住的(比如用的是同一个Class,同一种标签。)。这些都是可以程序化的东西。我们通过编程,将这些有规律的东西,用正则表达式来表达出来,然后交给代码去提取内容,这样就是爬虫爬取数据的具体表现了。

    MATLAB爬取股票数据

    相信大家听的比较多的应该是用 Python 来爬取网页数据了,但其实,Matlab 也是可以的,这里我们来具体实现一下。场景是这样的:

    1565940537135

    链接:http://vip.stock.finance.sina.com.cn/corp/go.php/vMS_MarketHistory/stockid/000001/type/S.phtml?year=2017&jidu=4

    新浪财经提供了历年各个季度的各股票数据,今天我们的任务就是,将上证综合指数(000001)1991年到1992年的数据爬取到,然后整理出来,保存到两个excel中,每个excel包括当年四个季度的数据,数据如上图所示,包括日期,开盘价、最高价、收盘价、最低价、交易量、交易金额。

    爬取流程

    本次爬取股票数据的流程是这样的:

    观察网址规律

    首先,观察当选择不同的年份与季度时,网页链接是有规律的:

    http://vip.stock.finance.sina.com.cn/corp/go.php/vMS_MarketHistory/stockid/000001/type/S.phtml?year=2017&jidu=4
    • stockid/000001 指明了所选股票代码
    • year=2017 指明了所选的年份
    • jidu=4 指明了所选季度

    那么,通过观察,我们就可以知道,当修改对应的数字,就可以获取到不同年份和季度下的数据网页了。在代码里设置两层循环就可以搞定了。

    提取网页内容

    确定网址后,我们可以利用函数获取到当前网址的源码,什么是源码?在网页里右键,查看源码你就知道了,长这样:

    1565941468623

    在Matlab里,提供了urlread函数来获取源码,语法参考如下:

    str = urlread(URL)
    str = urlread(URL,Name,Value)
    [str,status] = urlread(___)
    • str = urlread(URL) 将 HTML 网页内容从指定的 URL 下载到字符向量 str 中。urlread 不检索超链接目标和图像。
    • str = urlread(URL,Name,Value) 使用一个或多个 Name,Value 对组参数指定的其他选项。
    • [str,status] = urlread(___) 禁止显示错误消息,并使用先前语法中的任何输入参数。当操作成功时,status 为 1。否则,status 为 0

    也就是说,我们利用urlread函数会得到源码的文本。就像上图所示的那样,全是字符串。

    观察提取内容的规律

    我们提取的是股票的日期,开盘价、最高价、收盘价、最低价、交易量、交易金额。并且这些内容全部在源码里面了。源码是一堆乱七八糟的html标签还有Js等等。如何提取出我们想要的东西呢?这需要我们去观察源码。

    匹配日期

    首先定位到表格,通过F12,查看源码后,点击左下角的箭头,将箭头放到表格附近,就可以定位到元素的源码位置了。

    1565942251893

    其中日期的附近的源码是这样的:

    <div align="center">
                        <a target="_blank" href="http://vip.stock.finance.sina.com.cn/quotes_service/view/vMS_tradehistory.php?symbol=sh000001&amp;date=2017-12-28">
                2017-12-28          </a>
                            </div>

    仔细观察,在 2017-12-28 的前后都存在大量的空格,通过正则表达式,我们可以将其表述出来:

    \s+(\d\d\d\d-\d\d-\d\d)\s*

    怎么理解?\s+ 表示可以出现空格、换行、制表符等一次或者多次,(\d\d\d\d-\d\d-\d\d) 表示所有满足形如 2017-12-28这样的数字组合,\d代表0~9的阿拉伯数字,括号则表示所有满足这一组表达式匹配到的字符集合。最后\s*则表示末尾可以出现空格、换行、制表符等零次或者多次。通过正则表达式,可以提取到当前源码里所有满足这个规律的日期,从而返回相应的数据,这里使用matlab自带的regexp函数,具体语法如下:

    startIndex = regexp(str,expression)
    [startIndex,endIndex] = regexp(str,expression)
    out = regexp(str,expression,outkey)
    [out1,...,outN] = regexp(str,expression,outkey1,...,outkeyN)
    ___ = regexp(___,option1,...,optionM)
    ___ = regexp(___,'forceCellOutput')
    • startIndex = regexp(str,expression) 返回 str 中与该正则表达式指定的字符模式匹配的每个子字符串的起始索引。如果没有匹配项,则 startIndex 为空数组。
    • [startIndex,endIndex] = regexp(str,expression) 返回所有匹配项的开始和结束索引。
    • out = regexp(str,expression,outkey) 返回 outkey 指定的输出。例如,如果 outkey 为 'match',则 regexp 返回与该表达式匹配的子字符串而非其开始索引。
    • [out1,...,outN] = regexp(str,expression,outkey1,...,outkeyN) 按指定的顺序返回多个输出关键字指定的输出。例如,如果您指定 'match'、'tokens',则 regexp 返回与整个表达式匹配的子字符串以及与部分表达式匹配的标文。
    • ___ = regexp(___,option1,...,optionM) 使用指定的选项标志修改搜索。例如,指定 'ignorecase' 以执行不区分大小写的匹配。您可以包括任何输入并请求之前语法中的任何输出。
    • ___ = regexp(___,'forceCellOutput') 以标量元胞的形式返回每个输出参数。元胞包含被描述为上述语法输出的数值数组或子字符串。您可以包括任何输入并请求之前语法中的任何输出。

    匹配数据

    同理,我们也可以观察剩下的数据源码:

    <td><div align="center">3295.246</div></td>

    观察可以发现,数据都被<div align="center">xxx</div>所包住,所以正则表达式为:

    <div align="center">(\d*\.?\d*)</div>

    即被标签包住,且数据满足整数或者小数。

    数据整理与导出

    通过上面的正则表达提取字符串后,进行一些数据的整理,例如,字符串转数字,行列重排等等,然后将其写入到excel中。这里的步骤就不细说了。

    完整源码

    最后贴出源码(源码是在CSDN找到的,原链接:https://blog.csdn.net/miscclp/article/details/26839095

    % 本程序用于获取网站中的表格
     
     
    % written by longwen36
    % all rights reserved 
     
     
    clc,clear;
     
     
    warning off;
     
     
    for year = 1991:1992 %年份
        for jidu = 1:4
            
            fprintf('%d年%d季度的数据...', year, jidu)
            [sourcefile, status] = urlread(sprintf('http://vip.stock.finance.sina.com.cn/corp/go.php/vMS_MarketHistory/stockid/000001/type/S.phtml?year=%d&jidu=%d', year,jidu));
            
            if ~status
                error('读取出错!\n')
            end
            
            expr1 = '\s+(\d\d\d\d-\d\d-\d\d)\s*'; %获取日期
            [datefile, date_tokens]= regexp(sourcefile, expr1, 'match', 'tokens');
            
            
            date = cell(size(date_tokens));
            
            for idx = 1:length(date_tokens)
                date{idx} = date_tokens{idx}{1};
            end
              
            expr2 = '<div align="center">(\d*\.?\d*)</div>'; %获取数据
            
            [datafile, data_tokens] = regexp(sourcefile, expr2, 'match', 'tokens');
            
            data = zeros(size(data_tokens));
            
            for idx = 1:length(data_tokens)
                data(idx) = str2double(data_tokens{idx}{1});
            end
            
            data = reshape(data, 6, length(data)/6 )'; %重排
            
            filename = sprintf('%d年',year);
            pathname = [pwd '\data'];
            
            if ~exist(pathname,'dir')
                mkdir(pathname);
            end
            
            fullfilepath = [pwd '\data\' filename];
            % 保存数据到Excel
            sheet = sprintf('第%d季度', jidu);
            xlswrite(fullfilepath, date' , sheet);
            range = sprintf('B1:%s%d',char(double('B')+size(data,2)-1), size(data,1));
            xlswrite(fullfilepath, data, sheet, range);
            fprintf('OK!\n')
            
        end
    end
     
     
    fprintf('全部完成!\n')

    运行结果展示

    点击运行后,命令行窗口会提示当前状态:

    1565943200627

    每写入一个季度的数据,就会提示一次OK,直到全部完成。

    同时,在当前运行的文件下,会多出一个data文件夹,里面包括了1991和1992两个excel,打开后表格里有四个季度的数据:

    1565943307831

    1565943317010

    有关正则表达式

    转载于:https://www.cnblogs.com/gshang/p/11364855.html

    展开全文
  • 爬虫代码matlab jpgscraper JpgScraper:JPEG 文件的高级雕刻师 这是一个包装器存储库,介绍了在以下论文中使用和提出的工具。 请正确引用。 :从 993 种不同的文件数据类型中区分编码的 JPEG 数据的 AC# 工具。 ...
  • 这里复杂的情况暂时不考虑。。测试网址为pixiv的每日排行榜 = = url = '... text = webread(url) % urlopen函数也可以打开网页 link = regexp(text,'data-filter=".*?lazy-image"data-src="(htt...
  • 实现和操作明显比SOAP和XML-RPC更为简洁,可以完全通过HTTP协议实现,还可以利用缓存Cache来提高响应速 度,性能、效率和易用性上都优于SOAP协议。 语法 data = webread(url) data = webread(url,QueryName1,...
  • 本文主要讲述如何使用matlab对广州链家二手房进行爬虫,附上源代码以及解读,超详细!
  • 内容导航:Q1:MATLAB怎样从新浪财经获取股票交易数据.rar超跌反弹动力强等诸多优势,最关键的是中小盘股已经2年多牛市了,而经历过5年熊市的蓝筹股才涨一波,距离结束还很远。玉名认为对股民来说,敢入低吸后就更要敢于...
  • 典型相关分析matlab实现代码 Python - 100天从新手到大师 作者:骆昊 最近有很多想学习Python的小伙伴陆陆续续加入我们的交流群,目前我们的交流群人数已经超过一万人。我们的目标是打造一个优质的Python交流社区,...
  • 主要利用matlab中的webread 和regexp两个函数 二、爬虫思路 获取源码发现,歌手和歌曲都存在这个标签里 所以使用regexp正则匹配就好了 三、实现 clc;close all;clear all top = cell(501,2);% k=1;...
  • 基于Matlab给出了sina即时股票数据获取分析的算法,便于用户开展数据获取和分析工作。代码如下:function stockinfo = queryprice(stocktype, stockid)%stocktype 股票类型:sh和sz%stockid 股票编码:url = sprintf...
  • 本文主要就是对比用python写的一个谷歌翻译的爬虫,分享一下MATLAB代码,主要使用的函数就是urlread和regexp。 先看一下效果: 代码是这个样子的(两个文件一个主文件:Google_translate.m)一个函数文件...
  • 典型相关分析matlab实现代码 Python - 100天从新手到大师 Python应用领域和就业形势分析 简单的说,Python是一个“优雅”、“明确”、“简单”的编程语言。 学习曲线低,适合非专业人士 开源系统,拥有强大的生态圈 ...
  • 不过他们都是用python实现的,网上关于MATLAB爬取需要登录的网站资源较少,刚好今天研究了下,在此记录分享。 我用的是获取’User-Agent’和 'Cookie’直接请求登录,爬取内容为自己学院的历届就业信息。 1)首先...
  • 典型相关分析matlab实现代码 Python - 100天从新手到大师 作者-chars Python应用领域和就业形势分析 简单的说,Python是一个“优雅”、“明确”、“简单”的编程语言。 学习曲线低,非专业人士也能上手 开源系统,...
  • 典型相关分析matlab实现代码 Python - 100天从新手到大师 by 骆昊 Python应用领域和就业形势分析 简单的说,Python是一个“优雅”、“明确”、“简单”的编程语言。 学习曲线低,适合非专业人士 开源系统,拥有强大...
  • matlab机器学习预测股价+python爬虫

    千次阅读 2020-12-31 10:53:15
    爬虫爬去数据后,使用matlab的神经网络框架和径向基网络框架,通过前五天股市的开盘价预测后一天的收盘价。 配置python3环境,通过python爬虫爬取数据 pip3安装baostock pandas xlwt 爬取选定时期的股票当天开盘...
  • 典型相关分析matlab实现代码 Python - 100天从新手到大师 Python应用领域和就业形势分析 简单的说,Python是一个“优雅”、“明确”、“简单”的编程语言。 学习曲线低,适合非专业人士 开源系统,拥有强大的生态圈 ...
  • 服务架构师和开发人员想要这些服务变得易于实现、维护、扩展、伸缩。RESTful 架构允许这些,甚至更多。一般来说,RESTful 服务应该有下面的属性和特征,也就是我要详细描述的内容: 模型表示(Representations) ...
  • 典型相关分析matlab实现代码 Python - 100天从新手到大师 作者:骆昊 Python应用领域和就业形势分析 简单的说,Python是一个“优雅”、“明确”、“简单”的编程语言。 学习曲线低,非专业人士也能上手 开源系统,...
  • 典型相关分析matlab实现代码 Python - 100天从新手到大师 作者:骆昊 Python应用领域和就业形势分析 简单的说,Python是一个“优雅”、“明确”、“简单”的编程语言。 学习曲线低,适合非专业人士 开源系统,拥有...
  • 典型相关分析matlab实现代码 Python第三方库安装,点击链接 ,搜索所需的三方库的.whl文件,下载完成后修改为.zip,解压后将文件保存在python的lib,libs文件下 Python - 100天从新手到大师 转载 Python应用领域和...
  • MATLAB实现三边定位

    千次阅读 2017-10-10 17:32:00
    MATLAB实现 trilateration_position.m 1 % ----------------采用三边定位法对未知节点定位------------------------------- 2 3 %{ 4 clc命令是用来清除命令窗口的内容。不管开启多少个应用程序,命令...
  • 典型相关分析matlab实现代码 Python - 100天从新手到大师 Python应用领域和就业形势分析 简单的说,Python是一个“优雅”、“明确”、“简单”的编程语言。 学习曲线低,适合非专业人士 开源系统,拥有强大的生态圈 ...
  • 典型相关分析matlab实现代码 Python - 100天从新手到大师 源仓库链接: 作者:骆昊 Python应用领域和就业形势分析 简单的说,Python是一个“优雅”、“明确”、“简单”的编程语言。 学习曲线低,非专业人士也能上手...

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 3,339
精华内容 1,335
关键字:

matlab爬虫实现

matlab 订阅
爬虫 订阅