笔者用的是python3.6.5以及PyCharm不得不说,JetBrains做的IDE都很不错,无论是这款PyCharm还是IntelliJ
在形参处的名称提示太方便了
笔者学java的,本次写这个爬虫纯粹为了交作业
学过java的URL类的基本都明白
所为爬虫无非就是建立一个与某个网站的连接
通过该连接获取输入流,读取网站内容
实质上就是一个socket的输入输出操作,根据http状态码以及请求头里的信息,验证是否发送完毕(一般是200),结束连接
本次使用的爬取类库是python3.6的一个标准库
urllib不依赖任何第三方库,无需安装
通过以下代码
req=urllib.request.Request(url,header)
可以得到一个HttpRequest对象
再通过以下代码,发出该请求并得到一个HttpResponse对象
res=urllib.request.urlopen(req,context)
以上代码中,如果是http:开头的网站header和context都可以省略,则采用默认参数
而对于https开头的网站,因为要进行证书验证
所以要创建一个带ssl证书的context并传入
context = ssl._create_unverified_context()
通过以下方式创建header来指定模拟爬虫的浏览器信息
并在网站支持国际化时指定语言为中文
header = {
'Accept': 'text/html, application/xhtml+xml, */*',
'Accept-Language': 'zh-CN',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36',
'DNT': '1',
'Connection': 'Keep-Alive',
}
通过得到的response对象的read方法会返回页面内容的byte数组
而我们需要的是字符串
所以使用decode方法,对byte数组编码并转换成字符串
而网络传输的数据格式是json,所以使用json模块的load方法将得到的数据转换为json对象
总结以上几步,我们封装一下爬取资源的方法
def getUrlJson(inUrl):
req = urllib.request.Request(url=inUrl, headers=webheader)
webPage = urllib.request.urlopen(req,context=context)
data = webPage.read().decode('utf-8')
data = json.loads(data)
return data
通过调用该函数
data = getUrlJson(Url)
这样就得到了网页的内容
有个bug,有时候爬取一些网站会提示页面中存在0x8b这个值不能编码为utf-8中的字符
笔者上网百度了很久,包括在stackOverflow上查看相关问题
发现没有真正能解决的,像(注释掉Accept-encode,不注释对压缩giz进行处理,都不能解决)
然后在PyCharm中进行运行居然又不报这个错了…
也希望知道这个bug解决方法的,联系笔者QQ1183609515,谢谢
本次爬取的是选股宝这个股票网站上面所有股票的信息
作为一个股票网站,实时更新是必须的,所以肯定是个动态网站
选股宝https://xuangubao.cn/dingpan/
爬取下来页面内容后,输出查看
print(data)
结果是这个
<html data-n-head-ssr data-n-head="">
<head>
<meta data-n-head="true" name="referrer" content="always">
<meta data-n-head="true" name="renderer" content="webkit">
<meta data-n-head="true" name="force-rendering" content="webkit">
<meta data-n-head="true" name="baidu-site-verification" content="GFgkG2X61Y">
<meta data-n-head="true" http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
<meta data-n-head="true" charset="utf-8">
<meta data-n-head="true" name="viewport" content="width=device-width, initial-scale=1">
<meta data-n-head="true" data-hid="description" name="description" content="选股宝,一款主打“主题投资”的A股资讯神器,每日根据用户个性化关注主题,推送最新、最快、最狠的消息,帮助第一时间抓住机会。">
<meta data-n-head="true" data-hid="keywords" name="keywords" content="选股宝,xuangubao.cn,主题投资,资讯,股票,板块,题材,产业链,主题库,今日机会,中长线机会,近期风口,提前埋伏">
<title data-n-head="true">选题材抓龙头,就用选股宝 xuangubao.cntitle>
<link data-n-head="true" rel="icon" type="image/x-icon" href="/img/favicon.ico">
<link data-n-head="true" rel="stylesheet" type="text/css" href="//at.alicdn.com/t/font_117096_dawtptwmkjawnrk9.css">
<link data-n-head="true" rel="stylesheet" type="text/css" href="//cdn.bootcss.com/minireset.css/0.0.2/minireset.min.css">
<script data-n-head="true" src="/js/qrcode.js">script>
<script data-n-head="true" src="https://polyfillservice.wallstreetcn.com/v2/polyfill.js?features=default,es6,es7,fetch&unknown=polyfill&flags=gated">script>
<link rel="preload" href="https://static-alpha.wallstreetcn.com/clay/manifest.1f6b2202e79ed3bc8f71.js" as="script">
<link rel="preload" href="https://static-alpha.wallstreetcn.com/clay/vendor.787b748b2aa791af3419.js" as="script">
<link rel="preload" href="https://static-alpha.wallstreetcn.com/clay/app.a93c21ff1869eac54397.js" as="script">
<link rel="preload" href="https://static-alpha.wallstreetcn.com/clay/app.a22dace7c29e562d6288b8728abc210f.css" as="style">
<link rel="preload" href="https://static-alpha.wallstreetcn.com/clay/layouts/default.c8fc2ca668da67a5522f.js" as="script">
<link rel="preload" href="https://static-alpha.wallstreetcn.com/clay/pages/dingpan/_id.a8362de5e835a04f692c.js" as="script">
<link rel="prefetch" href="https://static-alpha.wallstreetcn.com/clay/pages/vip.cad641367f2be08dc49c.js">
<link rel="prefetch" href="https://static-alpha.wallstreetcn.com/clay/pages/theme/_id.c2cc1b6f07508499d2a7.js">
<link rel="prefetch" href="https://static-alpha.wallstreetcn.com/clay/pages/index.416454fc7d221d35ea69.js">
<link rel="prefetch" href="https://static-alpha.wallstreetcn.com/clay/pages/zhangjiazaozhidao.66e109fd0a57268089a9.js">
<link rel="prefetch" href="https://static-alpha.wallstreetcn.com/clay/pages/zaozhidao.fdf4f05456e0643e0f7d.js">
<link rel="prefetch" href="https://static-alpha.wallstreetcn.com/clay/pages/tuoshuiyanbao.535cdaa72fdb33b1618c.js">
<link rel="prefetch" href="https://static-alpha.wallstreetcn.com/clay/pages/tuoshuidiaoyan.914a90c524077a21b5c5.js">
<link rel="prefetch" href="https://static-alpha.wallstreetcn.com/clay/pages/panzhongtufa.9b33803561c97b306e26.js">
<link rel="prefetch" href="https://static-alpha.wallstreetcn.com/clay/pages/article/_id.3e1f7cf3ed25784ab36f.js">
<link rel="prefetch" href="https://static-alpha.wallstreetcn.com/clay/pages/premium-article/_id.1d8c500639f65de2abc7.js">
<link rel="prefetch" href="https://static-alpha.wallstreetcn.com/clay/pages/zhutiku.091e3e4f763c772dc931.js">
<link rel="prefetch" href="https://static-alpha.wallstreetcn.com/clay/pages/purchased-message.362581f93699b6157764.js">
<link rel="prefetch" href="https://static-alpha.wallstreetcn.com/clay/pages/subject/bkj/_id.cdc6888d383a44cb4697.js">
<link rel="prefetch" href="https://static-alpha.wallstreetcn.com/clay/pages/yuanchuang.ecbabd7749a1994c6d4e.js">
<link rel="prefetch" href="https://static-alpha.wallstreetcn.com/clay/pages/subject/_id.c5309899dee6e0d161e7.js">
<link rel="prefetch" href="https://static-alpha.wallstreetcn.com/clay/pages/stock/_symbol.d82369e79268ab7033fb.js">
<link rel="prefetch" href="https://static-alpha.wallstreetcn.com/clay/pages/chart.9d43c34c1e20b7540958.js">
<link rel="prefetch" href="https://static-alpha.wallstreetcn.com/clay/pages/agreement.cbb1a7e2159afe928317.js">
<link rel="prefetch" href="https://static-alpha.wallstreetcn.com/clay/pages/confirm-logout.2681979448cddb9bbea4.js">
<link rel="prefetch" href="https://static-alpha.wallstreetcn.com/clay/layouts/empty.3e708aa6c28c9df56ec8.js">
<link rel="prefetch" href="https://static-alpha.wallstreetcn.com/clay/pages/zhuti/_id.580075df75bf6c81393a.js">
<link rel="prefetch" href="https://static-alpha.wallstreetcn.com/clay/pages/ban/index.469b59d541cc54816be8.js">
<link rel="prefetch" href="https://static-alpha.wallstreetcn.com/clay/pages/ban/_id.7ea69e8444dc15b61cb5.js">
<link rel="stylesheet" href="https://static-alpha.wallstreetcn.com/clay/app.a22dace7c29e562d6288b8728abc210f.css">
<style data-vue-ssr-id="0780e740:0">.nav[data-v-789bdac6]{min-width:1200px;height:56px;line-height:56px;-webkit-box-shadow:0 2px 3px hsla(0,0%,4%,.1);box-shadow:0 2px 3px hsla(0,0%,4%,.1);background-color:#30333f;color:#fff}.nav .container[data-v-789bdac6]{width:1300px;margin:0 auto}.nav .nav-left[data-v-789bdac6]{float:left;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center}.nav .nav-right[data-v-789bdac6]{float:right}.nav .nav-right .nav-item[data-v-789bdac6]{color:#fff}.nav .nav-right .go-login[data-v-789bdac6],.nav .nav-right .log-out[data-v-789bdac6]{cursor:pointer}.nav .nav-item[data-v-789bdac6]{position:relative;color:#d8d8d8;height:56px;line-height:56px;margin-right:40px;-webkit-transition:.3s;transition:.3s}.nav .nav-item[data-v-789bdac6]:hover{color:#fff}.nav .nav-item.is-active-route[data-v-789bdac6]{border-bottom:3px solid #e6394d;pointer-events:none;color:#fff}.nav .nav-item .is-hot[data-v-789bdac6]{width:25px}.nav .logo[data-v-789bdac6]{margin-right:81px}.nav .logo img[data-v-789bdac6]{width:108px;height:26px}.nav .slogan[data-v-789bdac6]{display:inline-block;text-indent:-9999px;width:0}@media screen and (max-width:1366px){.nav .container[data-v-789bdac6]{width:1200px}}style>
<style data-vue-ssr-id="17042f68:0">.nav-item[data-v-0a76a5aa]{cursor:pointer;margin:0 0 0 -13px!important;padding:0 40px 0 13px}.nav-item img[data-v-0a76a5aa]{vertical-align:middle;margin-top:-2px;margin-left:2px}.nav-dropdown[data-v-0a76a5aa]{display:none;position:absolute;top:56px;left:0;background-color:#fff;-webkit-box-shadow:0 0 12px 0 rgba(0,0,0,.3);box-shadow:0 0 12px 0 rgba(0,0,0,.3);z-index:1000}.nav-dropdown.is-active[data-v-0a76a5aa]{display:block}.nav-dropdown[data-v-0a76a5aa]:before{content:"";position:absolute;top:-10px;left:20px;border:5px solid #fff;border-color:transparent;border-bottom-color:#fff}.nav-dropdown li[data-v-0a76a5aa]{width:160px;height:48px;line-height:48px}.nav-dropdown li a[data-v-0a76a5aa]{display:block;padding-left:16px;color:#666}.nav-dropdown li:hover a[data-v-0a76a5aa]{color:#333;background-color:#f5f5f5}style>
<style data-vue-ssr-id="18e89e59:0">.ban[data-v-34069733]{display:-webkit-box;display:-ms-flexbox;display:flex;width:100%;min-width:1280px;background:#292c33;min-height:100vh}.ban-main[data-v-34069733]{display:block;width:75%;min-width:1000px}.ban.simple .ban-main[data-v-34069733]{width:100%}.ban-chart-out[data-v-34069733]{width:100%;position:relative;background:#292c33;z-index:20}style>
<style data-vue-ssr-id="2b055f8b:0">.ban.normal .ban-table-tab.fixed,.ban.normal .hit-pool__table.table.fixed{max-width:auto;width:75%}.ban.simple .ban-chart,.ban.simple .ban-chart-out{width:1200px;margin:0 auto}.ban.simple .ban-table-tab{width:100%}.ban.simple .ban-table-tab .ban-table-tab-container{width:1200px;margin:0 auto;position:relative}.ban.simple .hit-pool__table.table.fixed{left:50%;margin-left:-600px}.ban.simple .ban-table-main{width:1200px;margin:0 auto;position:relative}@media screen and (max-width:1280px){.ban.simple{min-width:1000px}.ban.simple .ban-chart{width:1000px;margin:0 auto}.ban.simple .ban-table-tab{width:100%}.ban.simple .ban-table-tab .ban-table-tab-container{width:1000px;margin:0 auto;position:relative}.ban.simple .hit-pool__table.table.fixed{left:50%;margin-left:-500px}.ban.simple .ban-table-main{width:1000px;margin:0 auto;position:relative}.ban.simple .ban-chart-out{width:1000px;margin:0 auto}}.guide{position:fixed;top:0;bottom:0;left:0;right:0;z-index:9999;background:#262c32;overflow:scroll}.guide-container{width:900px;margin:0 auto;padding:60px 0 0}.guide-container-logo{position:relative;margin-bottom:20px}.guide-container-desc{font-size:16px;color:#fff;letter-spacing:0;line-height:24px;margin-top:20px}.guide .guide-video{margin:32px 0}.guide-start{bottom:0;height:100px;position:fixed;left:0;background:#2d303b;right:0;padding-top:20px;-webkit-box-shadow:0 0 12px 0 rgba(0,0,0,.15);box-shadow:0 0 12px 0 rgba(0,0,0,.15)}.guide-start-btn{opacity:.8;background:#e6394d;-webkit-box-shadow:0 0 16px 0 rgba(0,0,0,.3);box-shadow:0 0 16px 0 rgba(0,0,0,.3);color:#fff;font-size:16px;line-height:48px;text-align:center;margin:0 auto;cursor:pointer;width:240px;height:48px}.guide .video-js .vjs-big-play-button{top:50%;left:50%;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%)}.guide .vjs-custom-skin{margin:32px 0}style>
<style data-vue-ssr-id="52e02d56:0">.ban-chart[data-v-563fd61e]{display:-webkit-box;display:-ms-flexbox;display:flex;max-width:1200px;margin:0 auto;position:relative;height:96px;-ms-flex-pack:distribute;justify-content:space-around;padding-left:80px}.ban-chart-date[data-v-563fd61e]{width:64px;height:82px;margin-top:12px;background-color:#3f4352;position:absolute;left:15px;display:block;z-index:2;cursor:pointer}.ban-chart-date .ivu-date-picker[data-v-563fd61e]{position:relative;width:100%}.ban-chart-date .ivu-date-picker .ivu-select-dropdown[data-v-563fd61e]{border-radius:0}.ban-chart-date[data-v-563fd61e]:before{content:"";display:block;position:absolute;top:0;right:0;left:0;height:2px;background:#f2564e}.ban-chart-date[data-v-563fd61e]:after{content:"";display:block;position:absolute;bottom:0;right:0;left:0;height:10px;background:#292c33}.ban-chart-date-container[data-v-563fd61e]{padding-bottom:15px}.ban-chart-date-month-week[data-v-563fd61e]{color:#bcbcbc;font-size:12px;padding-top:6px;text-align:center}.ban-chart-date-day[data-v-563fd61e]{color:#fff;font-size:36px;line-height:36px;text-align:center;display:block;position:relative}.ban-chart-date-day[data-v-563fd61e]:before{content:"";display:block;position:absolute;bottom:-5px;left:27px;width:0;height:0;border-left:6px solid transparent;border-right:6px solid transparent;border-bottom:6px solid #636a7f}style>
<style data-vue-ssr-id="492747dc:0">.ban-chart-date{font-family:Helvetica Neue,Helvetica,Arial,PingFang SC,Hiragino Sans GB,Heiti SC,Microsoft YaHei,WenQuanYi Micro Hei,sans-serif}.ban-chart-date .ivu-date-picker .ivu-select-dropdown{border-radius:0}.ban-chart-date .ivu-date-picker .ivu-date-picker-header{background:#3e4352;border:none;color:#fff}.ban-chart-date .ivu-date-picker .ivu-date-picker-header .ivu-date-picker-next-btn-arrow-double,.ban-chart-date .ivu-date-picker .ivu-date-picker-header .ivu-date-picker-prev-btn-arrow-double{display:none}.ban-chart-date .ivu-date-picker .ivu-picker-panel-body:before{content:"";display:block;position:absolute;top:-6px;left:27px;width:0;height:0;border-left:6px solid transparent;border-right:6px solid transparent;border-bottom:6px solid #636a7f}.ban-chart-date .ivu-date-picker .ivu-picker-panel-content{background:#3e4352;padding:5px;position:relative}.ban-chart-date .ivu-date-picker .ivu-picker-panel-content:before{content:"";display:block;top:0;left:0;right:0;height:39px;position:absolute;background:#363a47}.ban-chart-date .ivu-date-picker .ivu-picker-panel-content .ivu-date-picker-cells{margin:0}.ban-chart-date .ivu-date-picker .ivu-picker-panel-content .ivu-date-picker-cells-header{background:#363a47;padding:3px 0;font-size:14px;position:relative}.ban-chart-date .ivu-date-picker .ivu-picker-panel-content .ivu-date-picker-cells-header span{color:#e6e6e6}.ban-chart-date .ivu-date-picker .ivu-picker-panel-content .ivu-date-picker-cells-cell{font-size:14px}.ban-chart-date .ivu-date-picker .ivu-picker-panel-content .ivu-date-picker-cells-cell em{color:#e6e6e6;border-radius:0}.ban-chart-date .ivu-date-picker .ivu-picker-panel-content .ivu-date-picker-cells-cell-next-month{display:none}.ban-chart-date .ivu-date-picker .ivu-picker-panel-content .ivu-date-picker-cells-cell-prev-month em{color:#3e4352}.ban-chart-date .ivu-date-picker .ivu-picker-panel-content .ivu-date-picker-cells-cell-selected em{color:#e6e6e6;position:relative;background:transparent}.ban-chart-date .ivu-date-picker .ivu-picker-panel-content .ivu-date-picker-cells-cell-selected em:before{content:"";display:block;bottom:0;left:3px;right:3px;height:2px;position:absolute;background:#f2564e}.ban-chart-date .ivu-date-picker .ivu-picker-panel-content .ivu-date-picker-cells-cell-today em{color:#e6e6e6;position:relative;background:transparent}.ban-chart-date .ivu-date-picker .ivu-picker-panel-content .ivu-date-picker-cells-cell-today em:after{content:"";display:none}.ban-chart-date .ivu-date-picker .ivu-picker-panel-content .ivu-date-picker-cells-cell:hover em{background:transparent;position:relative}.ban-chart-date .ivu-date-picker .ivu-picker-panel-content .ivu-date-picker-cells-cell:hover em:before{content:"";display:block;bottom:0;left:3px;right:3px;height:2px;position:absolute;background:#bcbcbc}.ban-chart-date .ivu-date-picker .ivu-picker-panel-content .ivu-date-picker-cells-cell-disabled{background:#3e4352}.ban-chart-date .ivu-date-picker .ivu-picker-panel-content .ivu-date-picker-cells-cell-disabled em{color:#666}.ban-chart-date .ivu-date-picker .ivu-picker-panel-content .ivu-date-picker-cells-cell-disabled:hover em:after{display:none}style>
<style data-vue-ssr-id="0b57cc23:0">.hit-pool-container[data-v-2209365c]{position:relative}.hit-pool-container .hit-pool-title[data-v-2209365c]{position:absolute;left:0;top:0}.hit-pool-container #fluctuation-c-label[data-v-2209365c]{position:absolute;right:20px;top:22px;color:#fff;font-size:10px}.hit-pool-container #fluctuation-c-label>p[data-v-2209365c]{-webkit-text-size-adjust:none;-moz-text-size-adjust:none;-ms-text-size-adjust:none;text-size-adjust:none;text-align:right;font-size:10px;line-height:25px}.hit-pool-container #fluctuation-title[data-v-2209365c]{position:absolute;top:5px;left:0;color:#fff;font-size:14px}.hit-pool-container #fluctuation-title-number[data-v-2209365c]{margin-left:5px;font-size:12px}style>
<style data-vue-ssr-id="7583bca5:0">.hit-pool-container[data-v-3bde4c92]{position:relative}.hit-pool-container .hit-pool-title[data-v-3bde4c92]{position:absolute;left:0;top:0}.hit-pool-container #limit-title[data-v-3bde4c92]{position:absolute;top:5px;left:0;color:#fff;font-size:14px}.hit-pool-container #limit-title-number[data-v-3bde4c92]{margin-left:5px;font-size:12px}.hit-pool-container #limit-label[data-v-3bde4c92]{position:absolute;right:20px;top:22px;color:#fff;font-size:10px}.hit-pool-container #limit-label>p[data-v-3bde4c92]{-webkit-text-size-adjust:none;text-align:right;font-size:10px;line-height:25px}style>
<style data-vue-ssr-id="10c98ab8:0">.hit-pool-container[data-v-b41f1032]{position:relative}.hit-pool-container .hit-pool-title[data-v-b41f1032]{position:absolute;left:0;top:0}.hit-pool-container #behavior_kline-label[data-v-b41f1032]{position:absolute;right:8px;top:22px;color:#fff;font-size:10px}.hit-pool-container #behavior_kline-label>p[data-v-b41f1032]{-webkit-text-size-adjust:none;text-align:right;font-size:10px;line-height:25px}.hit-pool-container #behavior_kline-title[data-v-b41f1032]{position:absolute;top:5px;left:0;color:#fff;font-size:14px}.hit-pool-container #behavior_kline-title-number[data-v-b41f1032]{margin-left:5px;font-size:12px}style>
<style data-vue-ssr-id="52a1965f:0">.hit-pool-container[data-v-dc69ee62]{position:relative}.hit-pool-container .hit-pool-title[data-v-dc69ee62]{position:absolute;left:0;top:0}.hit-pool-container #raise_incompleted_kline-title[data-v-dc69ee62]{position:absolute;top:5px;left:0;color:#fff;font-size:14px}.hit-pool-container #raise_incompleted_kline-title-number[data-v-dc69ee62]{margin-left:5px;font-size:12px}.hit-pool-container #raise_incompleted_kline-label[data-v-dc69ee62]{position:absolute;right:20px;top:22px;color:#fff;font-size:10px}.hit-pool-container #raise_incompleted_kline-label>p[data-v-dc69ee62]{-webkit-text-size-adjust:none;text-align:right;font-size:10px;line-height:25px}style>
<style data-vue-ssr-id="fe751746:0">.xgb-tools[data-v-c9b800e2]{position:fixed;right:40px;bottom:80px;cursor:pointer;-webkit-transition:.3s;transition:.3s}.tools-box[data-v-c9b800e2]{position:relative;width:28px;height:28px;line-height:28px;margin:0 auto 12px;text-align:center;border-radius:2px;background-color:#353a47;opacity:.8;-webkit-transition:.3s;transition:.3s}.tools-box[data-v-c9b800e2]:hover{opacity:1}.tools-box i[data-v-c9b800e2]{font-size:18px;color:#fff}.tools-appQrcode-image[data-v-c9b800e2]{visibility:hidden;position:fixed;bottom:120px;right:80px;width:100px;height:100px}.tools-wechatQrcode-image[data-v-c9b800e2]{visibility:hidden;position:fixed;bottom:80px;right:80px;width:100px;height:100px}.tools-box:hover .hint-text[data-v-c9b800e2],.tools-box:hover .tools-appQrcode-image[data-v-c9b800e2],.tools-box:hover .tools-wechatQrcode-image[data-v-c9b800e2]{visibility:visible}.hint-text[data-v-c9b800e2]{position:absolute;top:0;right:-30px;width:28px;height:28px;font-size:14px;line-height:1.1;visibility:hidden;text-align:left}@media screen and (max-width:1360px){.tools-box[data-v-c9b800e2]{opacity:.5}}style>
<style data-vue-ssr-id="6ee28bc2:0">.footer[data-v-04d5e15a]{min-width:1200px;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;height:80px;margin-top:60px;background:#353a47;color:#fff;font-size:10px;text-align:center}.footer .beian[data-v-04d5e15a]{color:#fff}.footer .gongan[data-v-04d5e15a]{width:14px;margin-right:3px}.footer .work-time[data-v-04d5e15a]{margin-left:15px}.footer .friend-link-container[data-v-04d5e15a]{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;font-size:12px;color:#7a8399;letter-spacing:0;line-height:20px}.footer .friend-link[data-v-04d5e15a]{margin-left:3px;font-size:12px;color:#7a8399;letter-spacing:0;line-height:20px}.footer .line-divider[data-v-04d5e15a]{display:block;height:9px;width:1px;background-color:#7a8399;margin-left:6px;margin-right:6px;margin-bottom:1px}style>
<style data-vue-ssr-id="78cb6622:0">.go-login[data-v-10973acc],.log-out[data-v-10973acc]{color:#fff;cursor:pointer}.nickname[data-v-10973acc]{color:#fff}.login-modal[data-v-10973acc],.reset-modal[data-v-10973acc],.success-modal[data-v-10973acc]{z-index:200}.modal-background[data-v-10973acc]{background-color:hsla(0,0%,4%,.4)}.success-modal .modal-content[data-v-10973acc]{width:440px;margin:0 20px;overflow:hidden}.success-modal .modal-content .success-close[data-v-10973acc]{position:absolute;z-index:100;top:10px;right:10px}.success-modal .modal-content .success-close[data-v-10973acc]:before{background:#d8d8d8;width:80%}.success-modal .modal-content .success-close[data-v-10973acc]:after{background:#d8d8d8;height:80%}.success-modal .modal-content .success-close[data-v-10973acc]:focus,.success-modal .modal-content .success-close[data-v-10973acc]:hover{background-color:#fff}.success-modal .modal-content .success-close[data-v-10973acc]:focus:before,.success-modal .modal-content .success-close[data-v-10973acc]:hover:before{background:#e6394d;width:80%}.success-modal .modal-content .success-close[data-v-10973acc]:focus:after,.success-modal .modal-content .success-close[data-v-10973acc]:hover:after{background:#e6394d;height:80%}.alert-modal .modal-card-head[data-v-10973acc]{text-align:center;padding:15px 20px}.alert-modal .modal-card-head .modal-card-title[data-v-10973acc]{font-size:16px;position:relative;left:8px}.alert-modal .alert-modal-info[data-v-10973acc]{text-align:center;font-size:20px}.alert-modal .modal-card[data-v-10973acc]{width:300px}.register[data-v-10973acc]{display:block;width:440px;position:relative;left:0;height:608px;background:#fff}.register-title[data-v-10973acc]{display:block;height:168px;position:relative;background:url("/img/login-bg.png");background-size:cover}.register-title-tab[data-v-10973acc]{display:-webkit-box;display:-ms-flexbox;display:flex;height:34px;width:440px;position:absolute;left:0;bottom:0}.register-title-tab label[data-v-10973acc]{height:34px;width:50%;display:block;color:#d8d8d8;cursor:pointer;text-align:center;font-size:18px;letter-spacing:.82px;line-height:18px}.register-title-tab label>span[data-v-10973acc]{display:inline-block;height:100%;border:none}.register-title-tab label.selecetd[data-v-10973acc]{height:34px;width:50%;cursor:pointer;color:#fff;text-align:center}.register-title-tab label.selecetd>span[data-v-10973acc]{display:inline-block;height:100%;border-bottom:3px solid #e6394d}.register-body[data-v-10973acc]{width:880px;display:-webkit-box;display:-ms-flexbox;display:flex}.register-body .register-body-log[data-v-10973acc],.register-body .register-body-reg[data-v-10973acc]{display:inline-block;width:440px;padding-top:40px;height:440px}.register-body .register-phone-input-err[data-v-10973acc]{display:block;padding-left:70px;height:30px;line-height:30px;font-size:12px;position:relative;color:#e6394d}.register-body .register-phone-input-err>.iconfont[data-v-10973acc]{margin-right:4px;position:relative;top:2px}.register-body .register-phone-input-err.show[data-v-10973acc]{opacity:1}.register-body .register-vcode-err[data-v-10973acc]{display:block;padding-left:70px;height:30px;line-height:30px;font-size:12px;position:relative;color:#e6394d;width:1px}.register-body .register-vcode-err>.iconfont[data-v-10973acc]{margin-right:4px;position:relative;top:2px}.register-body .register-vcode-err.show[data-v-10973acc]{opacity:1;width:auto}.register-body .register-pwd-err[data-v-10973acc]{display:block;padding-left:70px;height:30px;line-height:30px;font-size:12px;position:relative;color:#e6394d}.register-body .register-pwd-err>.iconfont[data-v-10973acc]{margin-right:4px;position:relative;top:2px}.register-body .register-pwd-err.show[data-v-10973acc]{opacity:1}.register-body .register-item[data-v-10973acc]{display:block;padding-left:40px;position:relative}.register-body .register-item .iconfont[data-v-10973acc]{font-size:24px;position:relative;top:4px;left:-5px}.register-body .register-item .iconfont.icon-pass[data-v-10973acc]{color:green;display:none}.register-body .register-item>input[data-v-10973acc]{font-size:16px;line-height:24px;border:none;outline:none;border-bottom:1px solid #efefef;width:328px;position:relative}.register-body .register-item>input[data-v-10973acc]:focus{border-bottom:1px solid #333}.register-body .register-item.on-error>input[data-v-10973acc]{border-bottom:1px solid #e6394d}.register-body .register-item.validate-pass .icon-pass[data-v-10973acc]{display:inline-block}.register-body .register-item.register-vcode[data-v-10973acc]{margin-top:20px;z-index:2}.register-body .register-item.register-vcode .register-vcode-input[data-v-10973acc]{padding-right:100px}.register-body .register-item.register-vcode .register-setpwd-input[data-v-10973acc]{padding-right:50px}.register-body .register-item.register-vcode .register-vcode-get[data-v-10973acc]{display:block;position:absolute;right:50px;top:8px;font-size:14px;line-height:18px;padding-left:10px;border-left:1px solid #efefef;cursor:pointer}.register-body .register-item.register-vcode .register-vcode-get[disabled=true][data-v-10973acc]{color:#666}.register-body .register-item.register-vcode .register-vcode-image[data-v-10973acc]{display:block;margin:5px 0 5px 160px;border:1px solid #d8d8d8;padding:8px 100px 10px 10px;position:absolute;bottom:-55px;left:0;-webkit-transition:all .3s;transition:all .3s}.register-body .register-item.register-vcode .register-vcode-image>img[data-v-10973acc]{display:block;width:96px;position:absolute;right:0;top:0;cursor:pointer}.register-body .register-item.register-vcode .register-vcode-image[data-v-10973acc]:before{content:"";position:absolute;top:-5px;right:10%;display:block;width:8px;height:8px;border-width:1px 1px 0 0;border-color:#999 #999 transparent transparent;border-style:solid;-webkit-transform:rotate(-45deg);transform:rotate(-45deg);background:#fff;z-index:1}.register-body .register-item.register-vcode .register-vcode-image-input[data-v-10973acc]{font-size:16px;line-height:24px;border:none;border:1px solid #d8d8d8;outline:none;width:120px;position:relative;padding-right:0}.register-body .register-item.register-vcode .register-vcode-image-input[data-v-10973acc]:focus{border:1px solid #353a47}.register-body .register-item.register-vcode .register-vcode-image-input.warning[data-v-10973acc]{border:1px solid #e6394d}.register-body .register-item.register-vcode .register-vcode-image-confirm[data-v-10973acc]{display:inline-block;position:absolute;height:26px;border-radius:10px;text-align:center;font-size:14px;line-height:26px;width:60px;top:8px;color:#fff;right:10px;cursor:pointer;background:gray}.register-body .register-item.register-vcode .register-vcode-image-confirm .active[data-v-10973acc]{background:#e6394d}.register-body .register-item.register-setpwd[data-v-10973acc]{margin-top:20px}.register-body .register-item.register-setpwd .register-setpwd-forget[data-v-10973acc]{display:block;position:absolute;right:50px;top:8px;font-size:14px;line-height:18px;padding-left:10px;cursor:pointer}.register-body .register-item.register-setpwd .register-setpwd-forget .register-pwd-switch[data-v-10973acc]{display:none}.register-body .register-item.register-setpwd .register-setpwd-forget .register-pwd-switch:empty~label[data-v-10973acc]{display:inline-block;position:relative}.register-body .register-item.register-setpwd .register-setpwd-forget .register-pwd-switch:empty~label>i[data-v-10973acc]{opacity:0;cursor:pointer}.register-body .register-item.register-setpwd .register-setpwd-forget .register-pwd-switch:empty~label[data-v-10973acc]:before{content:"\E60D";font-size:24px;font-family:iconfont;position:absolute;left:0;top:0;display:block}.register-body .register-item.register-setpwd .register-setpwd-forget .register-pwd-switch:checked~label[data-v-10973acc]{display:inline-block;position:relative}.register-body .register-item.register-setpwd .register-setpwd-forget .register-pwd-switch:checked~label>i[data-v-10973acc]{opacity:0;cursor:pointer}.register-body .register-item.register-setpwd .register-setpwd-forget .register-pwd-switch:checked~label[data-v-10973acc]:before{content:"\E60C";font-family:iconfont;font-size:24px;position:absolute;left:0;top:0;display:block}.register-body .login-phone-input-err[data-v-10973acc]{display:block;padding-left:70px;height:30px;line-height:30px;font-size:12px;position:relative;color:#e6394d}.register-body .login-phone-input-err>.iconfont[data-v-10973acc]{margin-right:4px;position:relative;top:2px}.register-body .login-phone-input-err.show[data-v-10973acc]{opacity:1}.register-body .login-pwd-err[data-v-10973acc]{display:block;padding-left:70px;height:30px;line-height:30px;font-size:12px;position:relative;color:#e6394d}.register-body .login-pwd-err>.iconfont[data-v-10973acc]{margin-right:4px;position:relative;top:2px}.register-body .login-pwd-err.show[data-v-10973acc]{opacity:1}.register-body .login-item[data-v-10973acc]{display:block;padding-left:40px;position:relative}.register-body .login-item .login-setpwd-input[data-v-10973acc]{padding-right:120px}.register-body .login-item .iconfont[data-v-10973acc]{font-size:24px;position:relative;top:4px;left:-5px}.register-body .login-item .iconfont.icon-pass[data-v-10973acc]{color:green;display:none}.register-body .login-item>input[data-v-10973acc]{font-size:16px;line-height:24px;border:none;outline:none;border-bottom:1px solid #efefef;width:328px;position:relative}.register-body .login-item>input[data-v-10973acc]:focus{border-bottom:1px solid #333}.register-body .login-item.on-error>input[data-v-10973acc]{border-bottom:1px solid #e6394d}.register-body .login-item.validate-pass .icon-pass[data-v-10973acc]{display:inline-block}.register-body .login-item.login-setpwd[data-v-10973acc]{margin-top:20px}.register-body .login-item.login-setpwd .login-setpwd-forget[data-v-10973acc]{display:block;position:absolute;right:50px;top:8px;font-size:14px;line-height:18px;padding-left:10px;cursor:pointer}.register-body .login-item.login-setpwd .login-setpwd-forget .login-pwd-switch[data-v-10973acc]{display:none}.register-body .login-item.login-setpwd .login-setpwd-forget .login-pwd-switch~label[data-v-10973acc]{display:inline-block;position:relative;line-height:24px}.register-body .login-item.login-setpwd .login-setpwd-forget .login-pwd-switch~label>i[data-v-10973acc]{opacity:0;cursor:pointer;margin-right:10px;vertical-align:top}.register-body .login-item.login-setpwd .login-setpwd-forget .login-pwd-switch~label>span[data-v-10973acc]{position:relative}.register-body .login-item.login-setpwd .login-setpwd-forget .login-pwd-switch:empty~label[data-v-10973acc]:before{content:"\E60D";font-family:iconfont;font-size:24px;position:absolute;left:0;top:0;display:block}.register-body .login-item.login-setpwd .login-setpwd-forget .login-pwd-switch:checked~label[data-v-10973acc]:before{content:"\E60C";font-family:iconfont;font-size:24px;position:absolute;left:0;top:0;display:block}.register-body .login-rememberme[data-v-10973acc]{margin-top:30px;padding-left:40px;font-size:12px}.register-body .login-btn[data-v-10973acc]{margin:20px 40px;width:360px;height:48px;background-color:#e6394d;cursor:pointer;text-align:center;color:#fff;line-height:48px;font-size:16px;letter-spacing:12px}.register-body .login-to-register[data-v-10973acc]{text-align:center;color:#666;font-size:14px}.register-body .login-to-register>span[data-v-10973acc]{color:#e6394d;cursor:pointer}.register-body .register-user-rule[data-v-10973acc]{margin-top:30px;padding-left:40px;font-size:12px}.register-body .register-btn[data-v-10973acc]{margin:20px 40px;width:360px;height:48px;background-color:#e6394d;cursor:pointer;text-align:center;color:#fff;line-height:48px;font-size:16px;letter-spacing:12px}.register-body .register-to-login[data-v-10973acc]{text-align:center;color:#666;font-size:14px}.register-body .register-to-login>span[data-v-10973acc]{color:#e6394d;cursor:pointer}.reset[data-v-10973acc]{display:block;width:440px;position:relative;left:0;height:608px;background:#fff}.reset-title[data-v-10973acc]{display:block;height:168px;position:relative;background:url("/img/reset-bg.png");background-size:cover}.reset-title .reset-back[data-v-10973acc]{height:30px;width:30px;position:relative;top:5px;left:5px;cursor:pointer}.reset-title .reset-back>i[data-v-10973acc]{font-size:24px;color:#fff;line-height:30px}.reset-body[data-v-10973acc]{width:440px;display:block;padding-top:40px}.reset-body .reset-phone-input-err[data-v-10973acc]{display:block;padding-left:70px;height:30px;line-height:30px;font-size:12px;position:relative;color:#e6394d}.reset-body .reset-phone-input-err>.iconfont[data-v-10973acc]{margin-right:4px;position:relative;top:2px}.reset-body .reset-phone-input-err.show[data-v-10973acc]{opacity:1}.reset-body .reset-vcode-err[data-v-10973acc]{display:block;padding-left:70px;height:30px;line-height:30px;font-size:12px;position:relative;color:#e6394d}.reset-body .reset-vcode-err>.iconfont[data-v-10973acc]{margin-right:4px;position:relative;top:2px}.reset-body .reset-vcode-err.show[data-v-10973acc]{opacity:1}.reset-body .reset-pwd-err[data-v-10973acc]{display:block;padding-left:70px;height:30px;line-height:30px;font-size:12px;position:relative;color:#e6394d}.reset-body .reset-pwd-err>.iconfont[data-v-10973acc]{margin-right:4px;position:relative;top:2px}.reset-body .reset-pwd-err.show[data-v-10973acc]{opacity:1}.reset-body .reset-item[data-v-10973acc]{display:block;padding-left:40px;position:relative}.reset-body .reset-item .iconfont[data-v-10973acc]{font-size:24px;position:relative;top:4px;left:-5px}.reset-body .reset-item .iconfont.icon-pass[data-v-10973acc]{color:green;display:none}.reset-body .reset-item>input[data-v-10973acc]{font-size:16px;line-height:24px;border:none;outline:none;border-bottom:1px solid #efefef;width:328px;position:relative}.reset-body .reset-item>input[data-v-10973acc]:focus{border-bottom:1px solid #333}.reset-body .reset-item.on-error>input[data-v-10973acc]{border-bottom:1px solid #e6394d}.reset-body .reset-item.validate-pass .icon-pass[data-v-10973acc]{display:inline-block}.reset-body .reset-item.reset-vcode[data-v-10973acc]{margin-top:20px;z-index:2}.reset-body .reset-item.reset-vcode .reset-vcode-input[data-v-10973acc]{padding-right:100px}.reset-body .reset-item.reset-vcode .reset-setpwd-input[data-v-10973acc]{padding-right:50px}.reset-body .reset-item.reset-vcode .reset-vcode-get[data-v-10973acc]{display:block;position:absolute;right:50px;top:8px;font-size:14px;line-height:18px;padding-left:10px;border-left:1px solid #efefef;cursor:pointer}.reset-body .reset-item.reset-vcode .reset-vcode-image[data-v-10973acc]{display:block;margin:5px 0 5px 160px;border:1px solid #d8d8d8;padding:8px 100px 10px 10px;position:absolute;bottom:-55px;left:0;-webkit-transition:all .3s;transition:all .3s}.reset-body .reset-item.reset-vcode .reset-vcode-image>img[data-v-10973acc]{display:block;width:96px;position:absolute;right:0;top:0;cursor:pointer}.reset-body .reset-item.reset-vcode .reset-vcode-image[data-v-10973acc]:before{content:"";position:absolute;top:-5px;right:10%;display:block;width:8px;height:8px;border-width:1px 1px 0 0;border-color:#999 #999 transparent transparent;border-style:solid;-webkit-transform:rotate(-45deg);transform:rotate(-45deg);background:#fff;z-index:1}.reset-body .reset-item.reset-vcode .reset-vcode-image-input[data-v-10973acc]{font-size:16px;line-height:24px;border:none;border:1px solid #d8d8d8;outline:none;width:120px;position:relative;padding-right:0}.reset-body .reset-item.reset-vcode .reset-vcode-image-input[data-v-10973acc]:focus{border:1px solid #353a47}.reset-body .reset-item.reset-vcode .reset-vcode-image-input.warning[data-v-10973acc]{border:1px solid #e6394d}.reset-body .reset-item.reset-vcode .reset-vcode-image-confirm[data-v-10973acc]{display:inline-block;position:absolute;height:26px;border-radius:10px;text-align:center;font-size:14px;line-height:26px;width:60px;top:8px;color:#fff;right:10px;cursor:pointer;background:gray}.reset-body .reset-item.reset-vcode .reset-vcode-image-confirm .active[data-v-10973acc]{background:#e6394d}.reset-body .reset-item.reset-setpwd[data-v-10973acc]{margin-top:20px}.reset-body .reset-item.reset-setpwd .reset-setpwd-forget[data-v-10973acc]{display:block;position:absolute;right:50px;top:8px;font-size:14px;line-height:18px;padding-left:10px;cursor:pointer}.reset-body .reset-item.reset-setpwd .reset-setpwd-forget .reset-pwd-switch[data-v-10973acc]{display:none}.reset-body .reset-item.reset-setpwd .reset-setpwd-forget .reset-pwd-switch:empty~label[data-v-10973acc]{display:inline-block;position:relative}.reset-body .reset-item.reset-setpwd .reset-setpwd-forget .reset-pwd-switch:empty~label>i[data-v-10973acc]{opacity:0;cursor:pointer}.reset-body .reset-item.reset-setpwd .reset-setpwd-forget .reset-pwd-switch:empty~label[data-v-10973acc]:before{content:"\E60D";font-size:24px;font-family:iconfont;position:absolute;left:0;top:0;display:block}.reset-body .reset-item.reset-setpwd .reset-setpwd-forget .reset-pwd-switch:checked~label[data-v-10973acc]{display:inline-block;position:relative}.reset-body .reset-item.reset-setpwd .reset-setpwd-forget .reset-pwd-switch:checked~label>i[data-v-10973acc]{opacity:0;cursor:pointer}.reset-body .reset-item.reset-setpwd .reset-setpwd-forget .reset-pwd-switch:checked~label[data-v-10973acc]:before{content:"\E60C";font-family:iconfont;font-size:24px;position:absolute;left:0;top:0;display:block}.reset-body .reset-btn[data-v-10973acc]{margin:20px 40px;width:360px;height:48px;background-color:#e6394d;cursor:pointer;text-align:center;color:#fff;line-height:48px;font-size:16px;letter-spacing:12px}.success[data-v-10973acc]{width:440px;left:0}.success-body[data-v-10973acc],.success[data-v-10973acc]{display:block;position:relative;height:608px;background:#fff}.success-body[data-v-10973acc]{background-size:cover}.success-body .success-login[data-v-10973acc],.success-body .success-register[data-v-10973acc],.success-body .success-reset[data-v-10973acc]{padding-top:180px}.success-body .success-login .iconfont[data-v-10973acc],.success-body .success-register .iconfont[data-v-10973acc],.success-body .success-reset .iconfont[data-v-10973acc]{font-size:80px;color:#e6394d;text-align:center;display:block}.success-body .success-login .success-text[data-v-10973acc],.success-body .success-register .success-text[data-v-10973acc],.success-body .success-reset .success-text[data-v-10973acc]{color:#e6394d;font-size:18px;text-align:center}.success-body .success-login .success-timer[data-v-10973acc],.success-body .success-register .success-timer[data-v-10973acc],.success-body .success-reset .success-timer[data-v-10973acc]{color:#999;font-size:14px;text-align:center}.success-body .success-reset-go-login[data-v-10973acc]{margin:20px 40px;margin-top:100px;width:360px;height:48px;background-color:#e6394d;cursor:pointer;text-align:center;color:#fff;line-height:48px;font-size:16px;letter-spacing:12px}style>
<style data-vue-ssr-id="bb78a7d4:0">.modal[data-v-0f33f7e0]{z-index:200}.login-modal .modal-content[data-v-0f33f7e0]{overflow:hidden;width:440px;margin:0 20px}.login-modal .modal-content .modal-close[data-v-0f33f7e0]{position:absolute;z-index:100;top:10px;right:10px}.login-modal .modal-content .modal-close[data-v-0f33f7e0]:after,.login-modal .modal-content .modal-close[data-v-0f33f7e0]:before{background-color:#999}style>
head>
<body data-n-head="">
<div data-server-rendered="true" id="__nuxt">
<div class="nuxt-progress" style="width:0%;height:2px;background-color:#3B8070;opacity:0;">div>
<div id="__layout">
<div>
<nav class="nav has-shadow" data-v-789bdac6>
<div class="container" data-v-789bdac6>
<div class="nav-left" data-v-789bdac6>
<a href="/" class="nav-item logo" data-v-789bdac6><h1 class="slogan" data-v-789bdac6>选题材抓龙头,就用选股宝 xuangubao.cn | 选股宝,一款主打“主题投资”的A股资讯神器,每日根据用户个性化关注主题,推送最新、最快、最狠的消息,帮助第一时间抓住机会。h1><img src="/img/logo.png" alt="选股宝 logo" data-v-789bdac6>a>
<a href="/" class="nav-item" data-v-789bdac6> 7 x 24 a>
<a href="/zhutiku" target="_blank" class="nav-item" data-v-789bdac6> 主题库 a>
<a href="/dingpan" target="_blank" class="nav-item nuxt-link-exact-active is-active-route" data-v-789bdac6> 智能盯盘 <img src="/img/HOT.png" class="is-hot" data-v-789bdac6>a>
<a href="/yuanchuang" target="_blank" class="nav-item" data-v-789bdac6> 原创 a>
<div target="_blank" class="nav-item" data-v-0a76a5aa data-v-789bdac6>
<span data-v-0a76a5aa>精选<img src="/img/tuoshui-badge.png" class="is-hot" data-v-0a76a5aa>span>
<ul class="nav-dropdown false" data-v-0a76a5aa>
<li data-v-0a76a5aa><a href="/tuoshuiyanbao" target="_blank" data-v-0a76a5aa>脱水研报a>li>
<li data-v-0a76a5aa><a href="/tuoshuidiaoyan" target="_blank" data-v-0a76a5aa>脱水调研a>li>
<li data-v-0a76a5aa><a href="/zaozhidao" target="_blank" data-v-0a76a5aa>选股宝早知道a>li>
<li data-v-0a76a5aa><a href="/panzhongtufa" target="_blank" data-v-0a76a5aa>选股宝盘中突发a>li>
<li data-v-0a76a5aa><a href="/zhangjiazaozhidao" target="_blank" data-v-0a76a5aa>选股宝涨价早知道a>li>
ul>
div>
div>
<div class="nav-right" data-v-789bdac6>
<span data-type="login" class="go-login nav-item" data-v-789bdac6>登录span>
<span data-type="register" class="go-login nav-item" data-v-789bdac6>注册span>
div>
div>
nav>
<div id="nuxt-layout-container">
<div class="ban dark normal" data-v-34069733>
<div class="ban-main" data-v-34069733>
<div class="ban-chart-out" data-v-563fd61e data-v-34069733>
<div class="ban-chart-date" data-v-563fd61e>
<div class="ivu-date-picker" data-v-563fd61e>
<div class="ivu-date-picker-rel">
<div class="ban-chart-date-container" data-v-563fd61e>
<p class="ban-chart-date-month-week" data-v-563fd61e> 6月周二 p>
<p class="ban-chart-date-day" data-v-563fd61e> 12 p>
div>
div>
<div class="ivu-select-dropdown" style="display:none;">
<div>
<div steps="" class="ivu-picker-panel-body-wrapper">
<div class="ivu-picker-panel-body">
<div class="ivu-date-picker-header">
<span class="ivu-picker-panel-icon-btn ivu-date-picker-prev-btn ivu-date-picker-prev-btn-arrow-double"><i class="ivu-icon ivu-icon-ios-arrow-left">i>span>
<span class="ivu-picker-panel-icon-btn ivu-date-picker-prev-btn ivu-date-picker-prev-btn-arrow"><i class="ivu-icon ivu-icon-ios-arrow-left">i>span>
<span><span class="ivu-date-picker-header-label">2018年span> <span class="ivu-date-picker-header-label">6月span>span>
<span class="ivu-picker-panel-icon-btn ivu-date-picker-next-btn ivu-date-picker-next-btn-arrow-double"><i class="ivu-icon ivu-icon-ios-arrow-right">i>span>
<span class="ivu-picker-panel-icon-btn ivu-date-picker-next-btn ivu-date-picker-next-btn-arrow"><i class="ivu-icon ivu-icon-ios-arrow-right">i>span>
div>
<div class="ivu-picker-panel-content">
<div class="ivu-date-picker-cells">
<div class="ivu-date-picker-cells-header">
<span> 日 span>
<span> 一 span>
<span> 二 span>
<span> 三 span>
<span> 四 span>
<span> 五 span>
<span> 六 span>
div>
<span class="ivu-date-picker-cells-cell ivu-date-picker-cells-cell-disabled ivu-date-picker-cells-cell-prev-month"><em>27em>span>
<span class="ivu-date-picker-cells-cell ivu-date-picker-cells-cell-prev-month"><em>28em>span>
<span class="ivu-date-picker-cells-cell ivu-date-picker-cells-cell-prev-month"><em>29em>span>
<span class="ivu-date-picker-cells-cell ivu-date-picker-cells-cell-prev-month"><em>30em>span>
<span class="ivu-date-picker-cells-cell ivu-date-picker-cells-cell-prev-month"><em>31em>span>
<span class="ivu-date-picker-cells-cell"><em>1em>span>
<span class="ivu-date-picker-cells-cell ivu-date-picker-cells-cell-disabled"><em>2em>span>
<span class="ivu-date-picker-cells-cell ivu-date-picker-cells-cell-disabled"><em>3em>span>
<span class="ivu-date-picker-cells-cell"><em>4em>span>
<span class="ivu-date-picker-cells-cell"><em>5em>span>
<span class="ivu-date-picker-cells-cell"><em>6em>span>
<span class="ivu-date-picker-cells-cell"><em>7em>span>
<span class="ivu-date-picker-cells-cell"><em>8em>span>
<span class="ivu-date-picker-cells-cell ivu-date-picker-cells-cell-disabled"><em>9em>span>
<span class="ivu-date-picker-cells-cell ivu-date-picker-cells-cell-disabled"><em>10em>span>
<span class="ivu-date-picker-cells-cell"><em>11em>span>
<span class="ivu-date-picker-cells-cell ivu-date-picker-cells-cell-selected ivu-date-picker-cells-cell-today"><em>12em>span>
<span class="ivu-date-picker-cells-cell ivu-date-picker-cells-cell-disabled"><em>13em>span>
<span class="ivu-date-picker-cells-cell ivu-date-picker-cells-cell-disabled"><em>14em>span>
<span class="ivu-date-picker-cells-cell ivu-date-picker-cells-cell-disabled"><em>15em>span>
<span class="ivu-date-picker-cells-cell ivu-date-picker-cells-cell-disabled"><em>16em>span>
<span class="ivu-date-picker-cells-cell ivu-date-picker-cells-cell-disabled"><em>17em>span>
<span class="ivu-date-picker-cells-cell ivu-date-picker-cells-cell-disabled"><em>18em>span>
<span class="ivu-date-picker-cells-cell ivu-date-picker-cells-cell-disabled"><em>19em>span>
<span class="ivu-date-picker-cells-cell ivu-date-picker-cells-cell-disabled"><em>20em>span>
<span class="ivu-date-picker-cells-cell ivu-date-picker-cells-cell-disabled"><em>21em>span>
<span class="ivu-date-picker-cells-cell ivu-date-picker-cells-cell-disabled"><em>22em>span>
<span class="ivu-date-picker-cells-cell ivu-date-picker-cells-cell-disabled"><em>23em>span>
<span class="ivu-date-picker-cells-cell ivu-date-picker-cells-cell-disabled"><em>24em>span>
<span class="ivu-date-picker-cells-cell ivu-date-picker-cells-cell-disabled"><em>25em>span>
<span class="ivu-date-picker-cells-cell ivu-date-picker-cells-cell-disabled"><em>26em>span>
<span class="ivu-date-picker-cells-cell ivu-date-picker-cells-cell-disabled"><em>27em>span>
<span class="ivu-date-picker-cells-cell ivu-date-picker-cells-cell-disabled"><em>28em>span>
<span class="ivu-date-picker-cells-cell ivu-date-picker-cells-cell-disabled"><em>29em>span>
<span class="ivu-date-picker-cells-cell ivu-date-picker-cells-cell-disabled"><em>30em>span>
<span class="ivu-date-picker-cells-cell ivu-date-picker-cells-cell-disabled ivu-date-picker-cells-cell-next-month"><em>1em>span>
<span class="ivu-date-picker-cells-cell ivu-date-picker-cells-cell-disabled ivu-date-picker-cells-cell-next-month"><em>2em>span>
<span class="ivu-date-picker-cells-cell ivu-date-picker-cells-cell-disabled ivu-date-picker-cells-cell-next-month"><em>3em>span>
<span class="ivu-date-picker-cells-cell ivu-date-picker-cells-cell-disabled ivu-date-picker-cells-cell-next-month"><em>4em>span>
<span class="ivu-date-picker-cells-cell ivu-date-picker-cells-cell-disabled ivu-date-picker-cells-cell-next-month"><em>5em>span>
<span class="ivu-date-picker-cells-cell ivu-date-picker-cells-cell-disabled ivu-date-picker-cells-cell-next-month"><em>6em>span>
<span class="ivu-date-picker-cells-cell ivu-date-picker-cells-cell-disabled ivu-date-picker-cells-cell-next-month"><em>7em>span>
div>
div>
<div class="ivu-picker-panel-content" style="display:none;">
div>
div>
div>
div>
div>
div>
div>
<div class="ban-chart" data-v-563fd61e>
<div class="hit-pool-container" data-v-2209365c data-v-563fd61e>
<div id="fluctuation" class="hit-pool-chart" style="width: 180px;height:96px;" data-v-2209365c>div>
<div id="fluctuation-title" class="hit-pool-title" data-v-2209365c>
涨跌对比
<span id="fluctuation-title-number" data-v-2209365c><span class="-market-color--red" data-v-2209365c>0span>:<span class="-market-color--green" data-v-2209365c>0span>span>
div>
<div id="fluctuation-c-label" data-v-2209365c>
<p data-v-2209365c>p>
<p data-v-2209365c>0p>
<p data-v-2209365c>p>
div>
div>
<div class="hit-pool-container" data-v-3bde4c92 data-v-563fd61e>
<div id="limit" class="hit-pool-chart" style="width: 180px;height:96px;" data-v-3bde4c92>div>
<div id="limit-title" class="hit-pool-title" data-v-3bde4c92>
涨跌停对比
<span id="fluctuation-title-number" data-v-3bde4c92>0 : 0span>
div>
<div id="limit-label" data-v-3bde4c92>
<p data-v-3bde4c92>p>
<p data-v-3bde4c92>0p>
<p data-v-3bde4c92>p>
div>
div>
<div class="hit-pool-container" data-v-b41f1032 data-v-563fd61e>
<div id="behavior_kline" class="hit-pool-chart" style="width: 180px;height:96px;" data-v-b41f1032>div>
<div id="behavior_kline-title" data-v-b41f1032>
昨日涨停今日表现
<span id="behavior_kline-title-number" data-v-b41f1032>0%span>
div>
<div id="behavior_kline-label" data-v-b41f1032>
<p data-v-b41f1032>0.00%p>
<p data-v-b41f1032>0.00%p>
<p data-v-b41f1032>0.00%p>
div>
div>
<div class="hit-pool-container" data-v-dc69ee62 data-v-563fd61e>
<div id="raise_incompleted_kline" class="hit-pool-chart" style="width: 180px;height:96px;" data-v-dc69ee62>div>
<div id="raise_incompleted_kline-title" data-v-dc69ee62>
封板未遂(炸板率:
<span id="behavior_kline-title-number" data-v-dc69ee62>0%span>)
div>
<div id="raise_incompleted_kline-label" data-v-dc69ee62>
<p data-v-dc69ee62>0p>
<p data-v-dc69ee62>0p>
<p data-v-dc69ee62>0p>
div>
div>
div>
div>
div>
div>
div>
<div class="xgb-tools" data-v-c9b800e2>
<div class="tools-box tools-appQrcode" data-v-c9b800e2>
<img src="/img/logo_dark.png" data-v-c9b800e2>
<img src="/img/xgb-app.png" alt="App下载二维码" class="tools-appQrcode-image" data-v-c9b800e2>
<span class="hint-text" data-v-c9b800e2>App下载span>
div>
<div class="tools-box tools-wechatQrcode" data-v-c9b800e2>
<i class="iconfont icon-weixin1" data-v-c9b800e2>i>
<img src="/img/xgb-wechat.jpeg" alt="微信公众号二维码" class="tools-wechatQrcode-image" data-v-c9b800e2>
<span class="hint-text" data-v-c9b800e2>公众号span>
div>
<div class="tools-box" data-v-c9b800e2>
<a href="http://biaoge.wallstreetcn.com/f/O88l5G" target="_blank" data-v-c9b800e2><i class="iconfont icon-fankui" data-v-c9b800e2>i>a>
<span class="hint-text" data-v-c9b800e2>用户反馈span>
div>
<div class="tools-box" data-v-c9b800e2>
<i class="iconfont icon-xiangshang" data-v-c9b800e2>i>
<span class="hint-text" data-v-c9b800e2>回到顶部span>
div>
div>
<footer class="footer" data-v-04d5e15a>
<p data-v-04d5e15a><a href="http://www.beian.gov.cn/portal/registerSystemInfo?recordcode=31010102003447" target="_blank" class="beian" data-v-04d5e15a><img src="/img/beian.png" alt="沪公网安备 31010102003447号" class="gongan" data-v-04d5e15a>沪公网安备 31010102003447号 a>p>
<p data-v-04d5e15a>© 2016 - 2018 选股宝-上海阿牛信息科技有限公司 xuangubao.cn <a href="http://www.miitbeian.gov.cn" target="_blank" class="beian" data-v-04d5e15a>沪ICP备13019121号-4a>p>
<p data-v-04d5e15a> 联系微信:xuangumei666 <span class="work-time" data-v-04d5e15a>工作时间:周一至周五 9:30-18:30span><span class="work-time" data-v-04d5e15a>中国(上海)自由贸易试验区张杨路707号二层西区span><span class="work-time" data-v-04d5e15a>风险提示:市场有风险,投资需谨慎span>p>
<p class="friend-link-container" data-v-04d5e15a> 友情链接: <a target="_blank" rel="noreferrer noopener" href="https://www.wallstreetcn.com/?from=xuangubao" class="friend-link" data-v-04d5e15a>华尔街见闻a><span class="line-divider" data-v-04d5e15a>span><a target="_blank" rel="noreferrer noopener" href="http://www.tubiaojia.com" class="friend-link" data-v-04d5e15a>图表家a><span class="line-divider" data-v-04d5e15a>span><a target="_blank" rel="noreferrer noopener" href="https://www.ipo3.com" class="friend-link" data-v-04d5e15a>犀牛之星a><span class="line-divider" data-v-04d5e15a>span><a target="_blank" rel="noreferrer noopener" href="https://www.caishiv.com" class="friend-link" data-v-04d5e15a>财视中国a><span class="line-divider" data-v-04d5e15a>span><a target="_blank" rel="noreferrer noopener" href="http://www.123.com.cn" class="friend-link" data-v-04d5e15a>云掌财经a><span class="line-divider" data-v-04d5e15a>span><a target="_blank" rel="noreferrer noopener" href="https://www.longau.com" class="friend-link" data-v-04d5e15a>龙讯财经a><span class="line-divider" data-v-04d5e15a>span><a target="_blank" rel="noreferrer noopener" href="http://www.315i.com" class="friend-link" data-v-04d5e15a>金联创a>p>
footer>
<div class="modal login-modal" data-v-0f33f7e0 data-v-10973acc>
<div class="modal-background" data-v-0f33f7e0>div>
<div class="modal-content" data-v-0f33f7e0>
<button class="modal-close modal-inner-close" data-v-0f33f7e0 data-v-10973acc>button>
<div class="register" data-v-0f33f7e0 data-v-10973acc>
<div class="register-title" data-v-0f33f7e0 data-v-10973acc>
<div class="register-title-tab" data-v-0f33f7e0 data-v-10973acc>
<label class="register-title-tab-radio selecetd" data-v-0f33f7e0 data-v-10973acc><span data-v-0f33f7e0 data-v-10973acc>登录span>label>
<label class="register-title-tab-radio" data-v-0f33f7e0 data-v-10973acc><span data-v-0f33f7e0 data-v-10973acc>注册span>label>
div>
div>
<div class="register-body" data-v-0f33f7e0 data-v-10973acc>
<div class="register-body-log" data-v-0f33f7e0 data-v-10973acc>
<div class="login-item login-phone" data-v-0f33f7e0 data-v-10973acc>
<i class="iconfont" data-v-0f33f7e0 data-v-10973acc>i>
<input placeholder="手机号" type="text" value="" class="login-item-input login-phone-input" data-v-0f33f7e0 data-v-10973acc>
<i class="iconfont icon-pass" data-v-0f33f7e0 data-v-10973acc>i>
div>
<div class="login-phone-input-err" data-v-0f33f7e0 data-v-10973acc>div>
<div class="login-item login-setpwd" data-v-0f33f7e0 data-v-10973acc>
<i class="iconfont" data-v-0f33f7e0 data-v-10973acc>i>
<input placeholder="密码" type="password" value="" class="login-item-input login-setpwd-input" data-v-0f33f7e0 data-v-10973acc>
<div class="login-setpwd-forget" data-v-0f33f7e0 data-v-10973acc>
<input type="checkbox" id="pwd-switch-login" name="pwd-switch-login" class="login-pwd-switch" data-v-0f33f7e0 data-v-10973acc>
<label for="pwd-switch-login" class="login-pwd-switch-label" data-v-0f33f7e0 data-v-10973acc><i class="iconfont" data-v-0f33f7e0 data-v-10973acc>i>label>
<span class="forget-pwd" data-v-0f33f7e0 data-v-10973acc>忘记密码span>
div>
div>
<div class="login-pwd-err" data-v-0f33f7e0 data-v-10973acc>div>
<div class="login-rememberme" data-v-0f33f7e0 data-v-10973acc>
<input type="checkbox" id="rememberme-switch" name="rememberme-switch" checked class="login-rememberme-switch" data-v-0f33f7e0 data-v-10973acc>
<label for="rememberme-switch" class="login-rememberme-switch-label" data-v-0f33f7e0 data-v-10973acc>记住我label>
div>
<div id="xgb-login" class="login-btn" data-v-0f33f7e0 data-v-10973acc>
登录
div>
<div class="login-to-register" data-v-0f33f7e0 data-v-10973acc>
还没有选股宝账号?
<span class="login-to-register-link" data-v-0f33f7e0 data-v-10973acc>立即注册span>
div>
div>
div>
div>
div>
div>
div>
div>
div>
<script type="text/javascript">window.__NUXT__={"layout":"default","data":[{"pageIndex":0,"pageMode":"normal","sideWidth":"25%","selectDate":"2018-06-12T02:10:29.910Z","timer":0,"topFixed":false,"yscrollVal":0,"smallScreen":false,"tabOffsetTop":152,"guideShow":false,"svgWidth":1000,"svgHeight":600,"yidongtixing":true,"show":false,"stopRefreshing":false,"tabItems":[{"index":0,"text":"盯盘","type":"ding","targetProp":"","poolPostfix":"","checked":false},{"index":1,"text":"涨停池","type":"boardstock","targetProp":"last_raise_time","poolPostfix":"board_code_desc","checked":false},{"index":2,"text":"炸板池","type":"boomstock","targetProp":"last_boom_time","poolPostfix":"boom_code_desc","checked":false},{"index":3,"text":"新股池","type":"newstock","targetProp":"new_stock_rule","poolPostfix":"new_code_desc","checked":false},{"index":4,"text":"次新股池","type":"secstock","targetProp":"px_change_rate","poolPostfix":"sec_code_desc","checked":false},{"index":5,"text":"强势股池","type":"multistock","targetProp":"continue_board_count","poolPostfix":"multi_code_desc","checked":false},{"index":6,"text":"跌停池","type":"downstock","targetProp":"last_board_time","poolPostfix":"","checked":false},{"index":7,"text":"昨日涨停池","type":"boardpreday","targetProp":"last_raise_time","poolPostfix":"","checked":false}],"playsinline":true,"playerOptions":{"muted":false,"width":900,"isFullscreen":true,"language":"zh-CN","sources":[{"type":"video\u002Fmp4","src":"http:\u002F\u002Fimage.bao.wallstreetcn.com\u002Fzhinengdingpan.mp4"}],"poster":"http:\u002F\u002Fimage.bao.wallstreetcn.com\u002Fding\u002Ffen3.png"}}],"error":null,"state":{"auth":{"token":null,"headers":{},"req":{}},"external":{"baiduTTSToken":{}},"home":{"ads":[],"hided":false},"homeMsgs":{"activeFixedSubjects":[],"hotSubjects":[],"activeHotSubjects":null,"msgs":[],"pushSettingsOpen":false,"push":{"notification":true,"audio":true,"tts":true},"isFetching":false,"reachedEnd":false,"cursor":{"headmark":"","tailmark":"","msgIdMark":"","hasExplain":""},"entities":{"msgs":{}},"entries":{"msgList":[]},"mode":"live","searchInfo":{"keyword":"","total":"","startDate":"","endDate":"","offset":0},"loading":false},"kline":{"count":200,"countStep":50,"zhutiKline":[],"stockKline":{},"stockKlineFields":[],"nomoreKline":false},"login":{"login":{"show":false,"mode":0}},"market":{"indexes":[{"Name":"上证指数","Symbol":"000001.SS"},{"Name":"深证成指","Symbol":"399001.SZ"},{"Name":"创业板指","Symbol":"399006.SZ"}],"quoteChange":{},"thermometer":{}},"premium":{"params":{"page":1,"limit":10},"msgs":[],"hotMsgs":[],"subjectInfo":{},"trialMsgs":[]},"purchasedMsgs":{"params":{"limit":10,"page":1},"msgs":null},"settings":{"trending":[],"settings":{"JinRiJiHuiQianZhan":[],"TiQianMaiFu":[],"ZhongChangXianJiHui":[]}},"stock":{"real":{},"stocks":[]},"stockImage":{"stockImage":{}},"stockSummary":{"fluctuationContrastData":null,"behaviorKlineData":null,"limitContrastData":null,"raiseIncompletedKlineData":null,"temperatureVal":null,"fluctuationDistributionData":null},"stockTrend":{"trend":null,"stockList":null,"preValue":null},"subscribe":{"isModalOpen":false,"message":null,"subject":{},"subjectItems":{"index":0,"items":[]},"selectedType":"","payMethod":"","payStatus":0,"order":{},"errmsg":""},"theme":{"themeInfo":null,"themeMsg":{},"plateSetInfo":{},"excpetionTheme":["24291465","24898553","17864537","19322062","17136297","17290881","27912881","27924249"],"themeStockSymbol":[],"outerStockSymbol":[],"themeStockList":[],"themeCount":{"raise":0,"down":0,"stable":0},"stockReal":{},"stockLabel":{},"themeSets":[],"accessMode":1,"stockFlow":null,"themeJinRiLongTou":null,"themeGoodBad":[],"eventHoverTime":null,"hideEvents":[],"financeDate":null,"finance":null,"themeFinance":null},"tuoshui":{"params":{"page":1,"limit":10},"Messages":{},"Subject":{},"NextMark":null,"hotMsgs":[],"trialMsgs":[]},"user":{"userInfo":{"isLogged":false,"Token":"","nickname":""}},"yuanchuang":{"top":[],"latest":[],"dayRank":[],"weekRank":[],"msgs":{}},"zaozhidao":{"params":{"page":1,"limit":10},"Messages":{},"Subject":{},"NextMark":null,"hotMsgs":[],"trialMsgs":[]},"zhutiChart":{"mode":"fenshi","diejia":[],"originIndex":[{"name":"沪深300","symbol":"000300.SS","px":null,"checked":true,"_index":0},{"name":"深证成指","symbol":"399001.SZ","px":null,"checked":false,"_index":1},{"name":"创业板指","symbol":"399006.SZ","px":null,"checked":false,"_index":2}],"timeRange":[]},"zhutiTongji":{"tongji":null,"tongjiMap":{},"stockClose":{},"tongjiTime":null,"tongjiLoading":false},"zhutiTrend":{"trend":null,"zhutiId":null,"preValue":null},"zhutiku":{"zhutikuAsc":[],"zhutikuDesc":[]}},"serverRendered":true};script>
<script src="https://static-alpha.wallstreetcn.com/clay/manifest.1f6b2202e79ed3bc8f71.js" defer>script>
<script src="https://static-alpha.wallstreetcn.com/clay/layouts/default.c8fc2ca668da67a5522f.js" defer>script>
<script src="https://static-alpha.wallstreetcn.com/clay/pages/dingpan/_id.a8362de5e835a04f692c.js" defer>script>
<script src="https://static-alpha.wallstreetcn.com/clay/vendor.787b748b2aa791af3419.js" defer>script>
<script src="https://static-alpha.wallstreetcn.com/clay/app.a93c21ff1869eac54397.js" defer>script>
<script>
{(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-64451198-4', 'auto');
ga('send', 'pageview');}
script>
<script>
(function(b,a,e,h,f,c,g,s){b[h]=b[h]||function(){(b[h].c=b[h].c||[]).push(arguments)};
b[h].s=!!c;g=a.getElementsByTagName(e)[0];s=a.createElement(e);
s.src="//s.union.360.cn/"+f+".js";s.defer=!0;s.async=!0;g.parentNode.insertBefore(s,g)
})(window,document,"script","_qha",219689,false);
script>
<script>
var _hmt = _hmt || [];
(function() {
var hm = document.createElement("script");
hm.async = 1
hm.src = "https://hm.baidu.com/hm.js?6e8f4dfa25ad4f956a55c8dd8d01fdec";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
script>
<script>
var _hmt = _hmt || [];
(function() {
var hm = document.createElement("script");
hm.src = "https://hm.baidu.com/hm.js?7e18ea40d71ecda0eacae51be020d9be";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
script>
body>
html>
与我们在浏览器里看到的页面不同,body中只有空标签
这是因为选股宝为了实时更新页面数据
内容都是通过js定时器定时发送ajax请求以后渲染数据到页面中
在浏览器中打开开发者模式(F12)查看刚刚爬取的网站的网络请求数据
发现有这个请求
这个url获取到的是所有的股票id
还有另一个重要的url
这个url可以根据id获取到对应的股票信息
根据这个:
queryProdCodeUrl='https://wows-api.wallstreetcn.com/v3/aioria/plates/summary/field?ids=all&fields=plate_id,stocks'
prodData = getUrlJson(queryProdCodeUrl)
queryInfoUrl='https://wows-api.wallstreetcn.com/real?fields=prod_name,px_change,last_px,px_change_rate,trade_status,circulation_value,pe_rate,market_value,turnover_ratio'
total=0
for item in prodData['data']['items']:
for iitem in prodData['data']['items'][item][1]['items']:
total=total+1
infoUrl = queryInfoUrl + '&en_prod_code=' + iitem[0]
snapshot = getUrlJson(infoUrl)['data']['snapshot']
snapshot = zip(snapshot['fields'],snapshot[iitem[0]])
for info in snapshot:
print(info[0],':',info[1],end=' ')
print('total:',total)
至此,就完成了爬区全股宝上的股票信息并输出
这里要用到第三方的库
xlwt
这是一个python向excel文件输出内容的库,不依赖其他第三方库
安装后
使用命令
xls = xlwt.Workbook()
sheet = xls.add_sheet('sample')
就创建了一个包含一个sample名字的sheet的xls文件对象
使用命令
sheet.write(row, col, data)
就可以将data的内容输出到该对象的row行从来列的格子
最后调用命令
xls.save(yourSavePath)
就可以把xls文件输出到给定目录
综上,我们只需要
在原有代码里修改下
total=0
xls = xlwt.Workbook()
sheet = xls.add_sheet('sample')
for item in prodData['data']['items']:
for iitem in prodData['data']['items'][item][1]['items']:
total=total+1
infoUrl = queryInfoUrl + '&en_prod_code=' + iitem[0]
snapshot = getUrlJson(infoUrl)['data']['snapshot']
snapshot = zip(snapshot['fields'],snapshot[iitem[0]])
col=0
for info in snapshot:
#print(info[0],':',info[1],end=' ')
sheet.write(total, col, info[1])
col=col+1
infoUrl = queryInfoUrl + '&en_prod_code=' + iitem[0]
snapshot = getUrlJson(infoUrl)['data']['snapshot']
snapshot = zip(snapshot['fields'],snapshot[iitem[0]])
col=0
for info in snapshot:
sheet.write(0, col, info[0])
col=col+1
xls.save(yourSavePath)
最后一段代码是把每个field的名字写入excel的第一行
最终查看目录文件
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-uuVUPnOu-1589093220299)(/blog/images/python/excelData.jpg)]
去除第一行的field名称
总共12924条股票信息
运行时间差不多一小时,才输出完毕
更多文章,请搜索公众号歪歪梯Club