[請益] phpquery抓網頁
最近抓網頁的時候
遇到一個網頁內有javascript
內容如下
<SCRIPT LANGUAGE="JavaScript">
function open_zoom_window()
{
OpenWindow=window.open("", "zoom_window", "height=, width=, toolbar=no,
scrollbars=no, menubar=no");
OpenWindow.document.write("<TITLE>Euro-Pro NJ600 3-Speed Blender</TITLE>")
OpenWindow.document.write("<BODY BGCOLOR=white>")
OpenWindow.document.write("<table width=100% height=100% valign=center>")
OpenWindow.document.write("<tr align=center><td><img
src=\"")" rel="nofollow">http://img.epinions.com\"></td></tr>")
OpenWindow.document.write("</table>")
OpenWindow.document.write("</BODY>")
OpenWindow.document.write("</HTML>")
OpenWindow.document.close()
self.name="main"
}
</SCRIPT>
因為javascript內有</BODY>
造成pq()在過濾tag的時候
到這邊就認為網頁結束了
不會再往下搜尋
不知道有沒有方法可以解決
讓他可以正確地搜尋整個網頁
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.113.128.14
→
03/22 13:00, , 1F
03/22 13:00, 1F
→
03/22 13:00, , 2F
03/22 13:00, 2F
那段確實不需要 最近才開始用phpquery
我是這樣寫
$url='網址';
curl_setopt($curl, CURLOPT_URL, $url);
$profile=curl_exec($curl);
$pq = phpQuery::newDocument($profile)
然後再用pq去過濾
請問要怎麼一開始就把它取代掉
※ 編輯: qk5669 來自: 140.113.73.167 (03/22 13:16)
※ 編輯: qk5669 來自: 140.113.73.167 (03/22 13:20)
推
03/22 13:43, , 3F
03/22 13:43, 3F
推
03/22 14:45, , 4F
03/22 14:45, 4F
最後我用preg_replace()和regexp把內容過濾掉
順利撈出資料
感謝各位幫忙
※ 編輯: qk5669 來自: 58.114.219.69 (03/24 14:55)
PHP 近期熱門文章
PTT數位生活區 即時熱門文章