抓取网页数据,上班亦能看股票
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">小伙伴们,你还好吗?</span></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">今天老祝和<span style="color: black;">大众</span><span style="color: black;">一块</span>学习一个导入网页数据的技巧。</span></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">非常多</span>时候,咱们<span style="color: black;">必须</span>将网页中的数据导入到Excel里做进一步的分析汇总,<span style="color: black;">例如</span><span style="color: black;">每日</span>的股市行情、外汇牌价、开奖信息等等。</span></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">接下来咱们演示一下,从下面这个网页中导入中国银行的每日外汇牌价。</span></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="https://mmbiz.qpic.cn/mmbiz_png/BAbVqibwwtmy4ZGItTLRFnBDaP6OVzQz7G9UOibRic7TAKrQXjibggbRFy9EHkxZfIFszCvrbHhf1xG4KUicibYgPHug/640?wx_fmt=png&tp=webp&wxfrom=5&wx_lazy=1&wx_co=1" style="width: 50%; margin-bottom: 20px;"></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">在这个网页中,外汇牌价的</span>信息一共有10页,<span style="color: black;">倘若</span><span style="color: black;">运用</span>Excel <span style="color: black;">初期</span>版本中的导入网页数据功能,默认只能导入<span style="color: black;">第1</span>页的信息。</span></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">接下来咱们以Excel 2019为例,说说导入<span style="color: black;">所有</span>10页信息的<span style="color: black;">详细</span>操作过程。</span></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="https://mmbiz.qpic.cn/mmbiz_png/BAbVqibwwtmy4ZGItTLRFnBDaP6OVzQz7HNCicuaTnNYMzw5AWAhJrxMwMOfI3ZFyx74wZXPPOssH9OkfCiaoMqCQ/640?wx_fmt=png&tp=webp&wxfrom=5&wx_lazy=1&wx_co=1" style="width: 50%; margin-bottom: 20px;"></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;"><span style="color: black;">过程</span>1</span></strong></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">依次单击【数据】→【自网页】,输入以下网页链接:</span></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">https://www.boc.cn/sourcedb/whpj/index_1.html</span></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">在【导航器】对话框中<span style="color: black;">选取</span> Table 0,将数据加载到Power Query编辑器。</span></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="https://mmbiz.qpic.cn/mmbiz_gif/BAbVqibwwtmy4ZGItTLRFnBDaP6OVzQz7yQevtnrxlF34YenMO4oQic2GhSSH59peDWS8XTVESSlibiaHyOf2vET7Q/640?wx_fmt=gif&tp=webp&wxfrom=5&wx_lazy=1" style="width: 50%; margin-bottom: 20px;"></p><span style="color: black;"><span style="color: black;">重视</span>此时只加载了<span style="color: black;">第1</span>页的信息,还<span style="color: black;">必须</span>咱们进一步的处理一下。</span>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;"><span style="color: black;">过程</span>2</span></strong></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">单击【高级编辑器】按钮,弹出【高级编辑器】对话框。在<span style="color: black;">let</span>语句之前添加以下内容,将<span style="color: black;">查找</span>转换为参数化的函数:</span></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;"><span style="color: black;"><span style="color: black;">(page </span><span style="color: black;">as number</span><span style="color: black;">) </span><span style="color: black;">as table=></span></span></span></strong></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">据述</span>这个两个as语句<span style="color: black;">指的是</span>定参数类型的,<span style="color: black;">这儿</span>咱们先暂时记住<span style="color: black;">这般</span>用。</span></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">接下来将url中<span style="color: black;">暗示</span>页面的数值“1”替换为以下内容,来构建一个动态的<span style="color: black;">查找</span>参数字符串:</span></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">" & Number.ToText(page) & "</span></strong></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="https://mmbiz.qpic.cn/mmbiz_png/BAbVqibwwtmy4ZGItTLRFnBDaP6OVzQz7SW1w0IibMCUxuSF6ia2EMazHYPo2WvOSkvGpNfN9RVw9gKPwibtvia9O4Q/640?wx_fmt=png&tp=webp&wxfrom=5&wx_lazy=1&wx_co=1" style="width: 50%; margin-bottom: 20px;"></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">单击【完成】按钮,会<span style="color: black;">显现</span><span style="color: black;">这般</span>的界面:</span></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="https://mmbiz.qpic.cn/mmbiz_png/BAbVqibwwtmy4ZGItTLRFnBDaP6OVzQz7icKWckdQGunU84OiaGnKXtBVibf6PfhN3InTJ78uGkaEiaZ0B9N8COI0mA/640?wx_fmt=png&tp=webp&wxfrom=5&wx_lazy=1&wx_co=1" style="width: 50%; margin-bottom: 20px;"></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;"><span style="color: black;">过程</span>3</span></strong></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">接下来要生成一组序号,<span style="color: black;">做为</span><span style="color: black;">刚才</span>定义的函数的页码参数。</span></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">在左侧的<span style="color: black;">查找</span>列表中单击右键,新建空<span style="color: black;">查找</span>。</span><span style="color: black;">在【高级编辑器】里输入以下内容:</span></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">{1..10}</span></strong></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">这儿</span>的10,<span style="color: black;">能够</span><span style="color: black;">按照</span><span style="color: black;">实质</span>页码数来确定。</span><span style="color: black;">最后单击【到表】按钮,转换为Table。</span></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="https://mmbiz.qpic.cn/mmbiz_gif/BAbVqibwwtmy4ZGItTLRFnBDaP6OVzQz7Gpm9F2DqLiac5ARGiajSrIymve8Det4Uiaq3eiaHEgH5eker9mgcktH9RA/640?wx_fmt=gif&tp=webp&wxfrom=5&wx_lazy=1" style="width: 50%; margin-bottom: 20px;"></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;"><span style="color: black;">过程</span>4</span></strong></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">双击<span style="color: black;">查找</span>名<span style="color: black;">叫作</span>“Table 0”,输入一个容易记忆的名<span style="color: black;">叫作</span>,<span style="color: black;">例如</span>“ Web”</span></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="https://mmbiz.qpic.cn/mmbiz_png/BAbVqibwwtmy4ZGItTLRFnBDaP6OVzQz7E0ibxqqEbz8uIADb0pXozblEyeiaz2mSKmZfkBqjdoTu8dkg4wFuQR8g/640?wx_fmt=png&tp=webp&wxfrom=5&wx_lazy=1&wx_co=1" style="width: 50%; margin-bottom: 20px;"></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;"><span style="color: black;">过程</span>5 </span></strong></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">在“<span style="color: black;">查找</span>1”中添加自定义列:</span></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">=Web()</span></strong></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="https://mmbiz.qpic.cn/mmbiz_gif/BAbVqibwwtmy4ZGItTLRFnBDaP6OVzQz7iaV3hrwCqg7LFDJ6DqLlYpez3UxZyQQegh3IOnWL9PGUVfl8nFhHiadw/640?wx_fmt=gif&tp=webp&wxfrom=5&wx_lazy=1" style="width: 50%; margin-bottom: 20px;"></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;"><span style="color: black;">过程</span>6</span></strong></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">因为</span>咱们定义的页数比网页中的<span style="color: black;">实质</span>页数要多,<span style="color: black;">因此</span>最后一行<span style="color: black;">显现</span>了错误值,<span style="color: black;">必须</span>先将其删除,<span style="color: black;">而后</span>再展开数据,加载到工作表中。</span></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="https://mmbiz.qpic.cn/mmbiz_gif/BAbVqibwwtmy4ZGItTLRFnBDaP6OVzQz7uChVEwWwB60Z4Vnyu6WZQOAA9OcFt7QHQuc8NS3Y9Mhb0J3Z0alh5w/640?wx_fmt=gif&tp=webp&wxfrom=5&wx_lazy=1" style="width: 50%; margin-bottom: 20px;"></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">最后,咱们还<span style="color: black;">能够</span>依次单击【数据】→【<span style="color: black;">所有</span>刷新】→【连接属性】,设置一下刷新频率,使Excel能够<span style="color: black;">根据</span>指定的时间在后台自动刷新:</span></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="https://mmbiz.qpic.cn/mmbiz_png/BAbVqibwwtmy4ZGItTLRFnBDaP6OVzQz71QLv3tBkxeIdicVdHaBuxbWOOmhYuC3gVs23wAmOibfoI2C76SiaMsPTQ/640?wx_fmt=png&tp=webp&wxfrom=5&wx_lazy=1&wx_co=1" style="width: 50%; margin-bottom: 20px;"></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">今天咱们的内容<span style="color: black;">便是</span>这些吧,祝小伙伴们和家人安好~~</span></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">图文制作:</span><span style="color: black;">祝洪忠</span></p>
软文发布平台 http://www.fok120.com/ 你的见解真是独到,让我受益良多。 对于这个问题,我有不同的看法... 软文发布平台 http://www.fok120.com/ 期待楼主的下一次分享!”
页:
[1]