使用coldfusion进行屏幕刮擦

时间:2014-03-26 17:36:37

标签: coldfusion screen-scraping cfhttp

我正在尝试使用Coldfusion中的以下代码来屏蔽另一个应用程序。

 <cfhttp url="https://intra.att.com/itscmetrics/EM2/LTMR.cfm" method="get" username="uvwxyz" password="abcdef">  

 <cfhttpparam type="url" name="LTMX" value="Andre Fuetsch / Shelly K Lazzaro">

</cfhttp> 

  <cfset myDocument = cfhttp.fileContent>

<cfoutput>
  #myDocument#
</cfoutput>

现在,当我运行cfm页面时,我可以使用上面的代码访问desitination页面。 目标页面如下所示。

enter image description here

源代码的一部分如下所示。

<table border="1" width=99% style="border-collapse:collapse;">
    <thead>
    <td colspan="12" class="drpmainheader1_2">LTM Detail Report for Andre Fuetsch / Shelly K Lazzaro</td>
    <tr align="center">
      <th class="ptitles">Liaison Name</th>
      <th class="ptitles">Application Acronym</th>
      <th class="ptitles">MOTS ID</th>
      <th class="ptitles">Priority</th> 
      <th class="ptitles">MC</th>
      <th class="ptitles">DR Exercise</th>
      <th class="ptitles">ARM/SRM Maintenance</th>
      <th class="ptitles">ARM/SRM Creation</th>             
      <th class="ptitles">Backup & Recovery Certification</th>
      <th class="ptitles">Interface Certification</th>
      <th class="ptitles">AIA Compliance</th>   
    </tr>
    </thead>

    <tbody>
    <tr>
    <td class="drpdetailtablerowdetailleft">Lynette M Acosta</td>
    <td class="drpdetailtablerowdetailleft">AABA</td>
    <td class="drpdetailtablerowdetail"><a href="http://ebiz.sbc.com/mots/detail.cfm?appl_id=9710" target="_blank" style="color:blue;">9710</a></td>
    <td class="drpdetailtablerowdetail">5</td>
    <td class="drpdetailtablerowdetail">NMC</td>
<td class="drpdetailtablerowdetail">Compliant</td> <td class="drpdetailtablerowdetail">Compliant</td> <td class="drpdetailtablerowdetail">Compliant</td> <td class="drpdetailtablerowdetail">Compliant</td> <td class="drpdetailtablerowdetail">Compliant</td> <td class="drpdetailtablerowdetail">Compliant</td>
    </tr>
    </tbody>

    <tbody>
    <tr>
    <td class="drpdetailtablerowdetailleft">Lynette M Acosta</td>
    <td class="drpdetailtablerowdetailleft">ABS RECON+</td>
    <td class="drpdetailtablerowdetail"><a href="http://ebiz.sbc.com/mots/detail.cfm?appl_id=13999" target="_blank" style="color:blue;">13999</a></td>
    <td class="drpdetailtablerowdetail">3</td>
    <td class="drpdetailtablerowdetail">NMC</td>
<td class="drpdetailtablerowdetail">Compliant</td> <td class="drpdetailtablerowdetail">Compliant</td> <td class="drpdetailtablerowdetail">Compliant</td> <td class="drpdetailtablerowdetail">Compliant</td> <td class="drpdetailtablerowdetail">Compliant</td> <td class="drpdetailtablerowdetail">Compliant</td>
    </tr>
    </tbody>

我对coldfusion中的正则表达式不太好,有人可以指导我或者给我任何关于如何使用Coldfusion从html表中提取数据的起点吗?我无法访问数据库。希望这很清楚。

1 个答案:

答案 0 :(得分:4)

使用正则表达式解析HTML?如果您使用带有ColdFusion的jsoup HTML Parser,您将拥有更多选项。 Jsoup使用类似jQuery的DOM选择器,可以快速将HTML表数据转换为数组。

http://jsoup.org/

以下是一些相关文章&amp;示例代码:

相关问题