2014-03-26 58 views
2

我想在Coldfusion中使用下面的代碼來屏蔽另一個應用程序。使用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頁,IAM能夠訪問輸出地址頁面,與上面的代碼。 目標頁面如下所示。

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

我希望這不是一個真實的用戶名和密碼。 –

回答

4

使用正則表達式解析HTML?如果您使用帶有ColdFusion的jsoup HTML解析器,那麼您將擁有更多選項。 Jsoup使用類似jQuery的DOM選擇器,並可以快速將HTML表格數據轉換爲數組。

http://jsoup.org/

這裏有一些相關的文章&示例代碼:

+0

謝謝...我以前沒有用過Coldfusion的任何java對象。我如何包含來自coldfusion的jsoup庫。我下載了jsoup jar文件,將它保存在我的目錄中,然後我做了這個,但是出現了一個錯誤。 Object Instantiation Exception。 找不到關鍵字:org.jsoup.Jsoup 有什麼想法? – user747291

+0

您可能想爲此問題在Serverfault.com上單獨提問 –

+2

這不是一個ServerFault問題!理想情況下,它應該是一個關於StackOverflow的新問題,但答案是確保將JAR放在正確的目錄中(與'cfusion.jar'相同的'lib'目錄)並重新啓動。在CF10中有一個管理員設置允許其他目錄中的jar文件,你也可以使用JavaLoader來定位特定的jar文件。 –