ExcelHome技术论坛

 找回密码
 免费注册

QQ登录

只需一步,快速开始

快捷登录

搜索
EH技术汇-专业的职场技能充电站 妙哉!函数段子手趣味讲函数 Excel服务器-会Excel,做管理系统 Excel Home精品图文教程库
HR薪酬管理数字化实战 Excel 2021函数公式学习大典 Excel数据透视表实战秘技 打造核心竞争力的职场宝典
300集Office 2010微视频教程 数据工作者的案头书 免费直播课集锦 ExcelHome出品 - VBA代码宝免费下载
用ChatGPT与VBA一键搞定Excel WPS表格从入门到精通 Excel VBA经典代码实践指南
查看: 1674|回复: 4

[求助] FILTERXML函数用法求助

[复制链接]

TA的精华主题

TA的得分主题

发表于 2020-10-19 16:01 | 显示全部楼层 |阅读模式
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件       ★免费下载 ★       ★ 使用帮助
请高手指点迷津。

想要获取下面包裹追踪页面的 包裹最新日期的最新状态。
https://trackings.post.japanpost.jp/services/srv/search/direct?searchKind=S002&locale=ja&reqCodeNo1=911777840993
A1单元格输入上面网址
A2单元格输入=webservice(A1)
A3单元格输入=FILTERXML(A2,Xpath)
包裹最新状态的xpath用chrome 提取的,跟论坛附件下载软件提取的都不行。都显示#VAUE
chrome提取的xpath如下                          //*[@id="content"]/form/div/table[2]/tbody/tr[15]/td[2]

软件提取的xpath如下         //form[@name='srv_searchActionForm']/div/table[2]/tbody/tr[15]/td[2]
*********************************************************************************
google sheet在线表格 使用 //*[@id="content"]/form/div/table[2]/tbody/tr[last()-1]/td[2] 能够实现目的,无奈速度太慢,效率太低。
***********************************************************************************************************
----------------------------------------------------------------------------------------------------------------------------------------------------------------
页面的xml如下:(红色部分为想要提取的内容)

<table class=""tableType01 txt_c m_b5"" summary=""配達状況詳細"">
              <tr>            
                       <th scope=""row"" class=""bg01 w_120"">お問い合わせ番号</th>
                        <th scope=""row"" class=""bg01 w_180"">商品種別</th>
                        <th scope=""row"" class=""bg01 w_100"">付加サービス</th>
                        <th scope=""row"" class=""bg01 w_80"">サイズ</th>
                        <th scope=""row"" class=""bg01 w_100"">お届け指定日</th>
                        <th scope=""row"" class=""bg01 w_80"">指定時間帯</th>

              </tr>
              <tr>

                        <td class=""w_120"">9117-7784-0993</td>
                        <td class=""w_180"">代金引換ゆうパック(都度送金)</td>
                        <td class=""w_100"">代引一般</td>
                        <td class=""w_80"">60</td>
                        <td class=""w_100""></td>
                        <td class=""w_80"">指定しない</td>
               </tr>
                <tr>
                    <th scope=""row"" class=""bg01 w_120"">配達予定局</th>
                    <th scope=""row"" class=""bg01 w_180"">複数個口数</th>
                       <th scope=""row"" class=""bg01 w_100""></th>
                            <th scope=""row"" class=""bg01 w_80""></th>
                            <th scope=""row"" class=""bg01 w_100""></th>
                            <th scope=""row"" class=""bg01 w_80""></th>
                </tr>
                <tr>
                    <td class=""w_120"">秋田中央郵便局</td>
                    <td class=""w_180"">0</td>
                            <td class=""w_100""> </td>
                            <td class=""w_80""> </td>
                            <td class=""w_100""> </td>
                            <td class=""w_80""> </td>

                </tr>

            </table>

            <br>

            <div class=""beige_box m_b15"">
                <h2 class=""beige_box_inner txt_type06 bold"">履歴情報</h2>
            </div>

            <table class=""tableType01 txt_c m_b5"" summary=""履歴情報"">
              <tr>
                        <th scope=""row"" rowspan=""2"" class=""bg01 w_120"">状態発生日</th>

                <th scope=""row"" rowspan=""2"" class=""bg01 w_150"">配送履歴</th>
                <th scope=""row"" rowspan=""2"" class=""bg01 w_180"">詳細</th>
                <th scope=""row"" class=""bg01 w_105"">取扱局</th>

                        <th scope=""row"" rowspan=""2"" class=""bg01 w_105"">県名等</th>
              </tr>
              <tr>
                <th scope=""row"" class=""bg01 w_105"">便番号</th>
              </tr>

                  <tr>
                    <td rowspan=""2"" class=""w_120"">2020/10/03 15:53</td>
                    <td rowspan=""2"" class=""w_150"">引受</td>
                    <td rowspan=""2"" class=""w_180""></td>
                    <td class=""w_105"">西成郵便局</td>
                    <td rowspan=""2"" class=""w_105"">大阪府</td>
                  </tr>
                  <tr>
                    <td class=""w_105"">557-8799</td>
                  </tr>     
                  <tr>
                    <td rowspan=""2"" class=""w_120"">2020/10/03 19:36</td>
                    <td rowspan=""2"" class=""w_150"">中継</td>
                    <td rowspan=""2"" class=""w_180""></td>
                    <td class=""w_105"">新大阪郵便局</td>
                    <td rowspan=""2"" class=""w_105"">大阪府</td>
                  </tr>
                  <tr>
                    <td class=""w_105"">539-8799</td>
                  </tr>
                  <tr>
                    <td rowspan=""2"" class=""w_120"">2020/10/04 12:02</td>
                    <td rowspan=""2"" class=""w_150"">中継</td>
                    <td rowspan=""2"" class=""w_180""></td>
                    <td class=""w_105"">岩手郵便局</td>
                    <td rowspan=""2"" class=""w_105"">岩手県</td>
                  </tr>
                  <tr>
                    <td class=""w_105"">029-8799</td>
                  </tr>
                  <tr>
                    <td rowspan=""2"" class=""w_120"">2020/10/04 14:54</td>
                    <td rowspan=""2"" class=""w_150"">到着</td>
                    <td rowspan=""2"" class=""w_180""></td>
                    <td class=""w_105"">秋田中央郵便局</td>
                    <td rowspan=""2"" class=""w_105"">秋田県</td>
                  </tr>
                  <tr>
                    <td class=""w_105"">010-8799</td>
                  </tr>
                  <tr>
                    <td rowspan=""2"" class=""w_120"">2020/10/04</td>
                    <td rowspan=""2"" class=""w_150"">ご不在のため持ち戻り</td>
                    <td rowspan=""2"" class=""w_180""></td>
                    <td class=""w_105"">秋田中央郵便局</td>
                    <td rowspan=""2"" class=""w_105"">秋田県</td>
                  </tr>
                  <tr>
                    <td class=""w_105"">010-8799</td>
                  </tr>      
                  <tr>
                    <td rowspan=""2"" class=""w_120"">2020/10/05</td>
                    <td rowspan=""2"" class=""w_150"">配達希望受付</td>
                    <td rowspan=""2"" class=""w_180"">配達予定日:10月5日 19~21時</td>
                    <td class=""w_105"">インターネット&#12539;IVR</td>
                    <td rowspan=""2"" class=""w_105""></td>
                  </tr>
                  <tr>
                    <td class=""w_105""> </td>
                  </tr>
                  <tr>
                    <td rowspan=""2"" class=""w_120"">2020/10/05 19:07</td>
                    <td rowspan=""2"" class=""w_150"">お届け先にお届け済み</td>
                    <td rowspan=""2"" class=""w_180""></td>
                    <td class=""w_105"">秋田中央郵便局</td>
                    <td rowspan=""2"" class=""w_105"">秋田県</td>
                  </tr>
                  <tr>
                    <td class=""w_105"">010-8799</td>
                  </tr>

            </table>


--------------------------------------------------------------------------------------------------------------------------------
截图1.jpg

https://trackings.post.japanpost.jp/services/srv/search/direct?searchKind=S002&locale=ja&reqCodeNo1=911777840982(次链接用来验证用)

TA的精华主题

TA的得分主题

 楼主| 发表于 2020-10-20 08:04 | 显示全部楼层
请高手指点迷津

TA的精华主题

TA的得分主题

发表于 2020-10-20 10:22 | 显示全部楼层
一.excel 收到的网页长度是有限制的,一般得不到全部网页,
      因为数据完整性问题不能解析,还有些网页不是完全符合xml格式的存在,也不能解析。
二.再有即使xml格式符合,因为取到的网页中不完整,刚好需要的内容不存在,那也是没有办法完成的。
除非是直接的xml格式,结构紧凑,不会超过字符长度。

你的问题第一点为主,第二点我没细看。
所以直接用excel的 FILTERXML函数 没办法解决你的网抓。

评分

1

查看全部评分

TA的精华主题

TA的得分主题

发表于 2020-10-20 13:34 来自手机 | 显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用  · 内置多项VBA编程加强工具       ★ 免费下载 ★      ★使用手册
playboy54873 发表于 2020-10-20 08:04
请高手指点迷津

自定义一个。
用这个看看吧

=webservice("http://e.anyoupin.cn/git/jppost/?c=https://trackings.post.japanpost.jp/services/srv/search/direct?searchKind=S002&locale=ja&reqCodeNo1=911777840982")

或者
=webservice("http://e.anyoupin.cn/git/jppost/?c=https%3A%2F%2Ftrackings.post.japanpost.jp%2Fservices%2Fsrv%2Fsearch%2Fdirect%3FsearchKind%3DS002%26locale%3Dja%26reqCodeNo1%3D911777840993")
収*O_20201020_132049.png

TA的精华主题

TA的得分主题

发表于 2021-7-25 17:35 | 显示全部楼层
您需要登录后才可以回帖 登录 | 免费注册

本版积分规则

关闭

最新热点上一条 /1 下一条

手机版|关于我们|联系我们|ExcelHome

GMT+8, 2024-4-18 23:22 , Processed in 0.041236 second(s), 13 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 1999-2023 Wooffice Inc.

沪公网安备 31011702000001号 沪ICP备11019229号-2

本论坛言论纯属发表者个人意见,任何违反国家相关法律的言论,本站将协助国家相关部门追究发言者责任!     本站特聘法律顾问:李志群律师

快速回复 返回顶部 返回列表