我可以使用 cfhttp 从外部站点中删除分页吗?



我正在我的网站上获取一个网站结果,如果还有更多记录,分页也会随之而来,所以它显示分页和记录

这不仅仅是一个问题,而不是在我进行任何尝试之前,我不知道从哪里开始

这可能吗,我可以通过某些客户端或服务器端对结果进行无限分页吗,请告诉我谢谢

分页在cfhttp.filecontent中如下所示:

<TD align="right" width="100"><font class="MainBody">Pages:&nbsp;&nbsp;<a href="http://websiteaddress.com/9.asp?type=10&pagenum=1"><<</a>&nbsp;&nbsp;1&nbsp;<a href="http://websiteaddress.com/9.asp?type=10&pagenum=2">2</a>&nbsp;&nbsp;&nbsp;<a href="http://websiteaddress.com/9.asp?type=10&pagenum=2">>></a>&nbsp;&nbsp;&nbsp;</FONT></TD>

这应该适合您。它搜索TD标签,后跟FONT标签,然后搜索页面。然后搜索到第一个关闭的TD。

结果存储在新文件内容中。

<cfset newfilecontent = REReplaceNoCase(cfhttp.filecontent,"<td.*?><font.*?>Pages.*?</td>","","ALL")>

有了更详细的问题,你需要的基本上是一只基本的蜘蛛。

这仅设计为从结果的第一页开始工作。你不能把它定位在第 3 页,然后得到第 2 页和第 1 页。

<cfhttp...> <!--- initial cfhttp --->
<cfset buildContents = ArrayNew(1)>
<cfset buildContents[1] = ReReplaceNoCase(cfHttp.fileContent,".*<body.*?>(.*)</body>.*","1","ALL")>
<!--- Quick regex to parse the contents of the body tag out of the cfhttp --->
<cfloop condition="#ReFindNoCase("(http[^""]*?pagenum=d+)(?="">>>)",currentContent)# gt 0">
    <cfset GetNextPage = ReMatchNoCase("(http[^""]*?pagenum=d+)(?="">>>)",currentContents)>
    <cfhttp url="#GetNextPage[1]#"... result="inLoop">
    <cfset currentContents = ReReplaceNoCase(inLoop.filecontent,".*<body.*?>(.*)</body>.*","1","ALL")>
    <cfset ArrayAppend(buildContents,REReplaceNoCase(currentContents,"<td.*?><font.*?>Pages.*?</td>","","ALL"))>
    <cfif ArrayLen(buildContents) gt 10>
      <!--- This code is untested, so this is a safety that you can remove or modify. If BuildContents has more than ten elements, it stops the looping. You can remove this cfif or maybe raise the number as a safety net.--->
      <cfbreak>
    </cfif>
</cfloop>
<cfdump var="#buildContents#">

最新更新