作者kornelius (Kornelius)
看板PHP
標題Re: [請益] 遠端網頁抓取字串的問題
時間Fri May 18 13:31:17 2007
用 http 可以解決
http://www.php.net/manual/en/ref.http.php
CURL 也能解決了,但是如果你不懂原理都是枉然。
http://www.php.net/manual/en/ref.curl.php
不然更低階一點,用 Socket ...
Socket
http://www.php.net/manual/en/ref.sockets.php
※ 引述《fillmore (.......................)》之銘言:
: 尚未解決
: web server看到的跟你client直接讀取網頁的結果會不同,不能夠叫web server去抓網頁
: 結果
恩...幫你抓網頁的應該不是叫做 "web server" 的東西吧?
: 讀網頁 file ("http://url");
file 是會傳回陣列,要處理 tag 最好用 file_get_contents
: 至於抓 tag
: strip_tags ( string str [, string allowable_tags] )
strip tags 是用來去除 tag 用的。不是抓 tag.........
: 還有 regular expression
: 自己去研究吧
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 61.223.99.44
※ 編輯: kornelius 來自: 61.223.99.44 (05/18 13:32)
推 foxzgerald:除了 cli 之外,執行 php 的不就是 server 嘛 :P ? 05/18 13:44
推 fillmore:我不是說不能夠抓阿可是抓到的就會不是我想要的了 05/18 13:56
推 kornelius:web server 只負責呈現 php 產生的結果。 05/18 14:08
推 foxzgerald:用 php 寫個 client 模擬器放在 server 上 05/18 15:21
→ fillmore:我的確是這樣寫 05/18 16:11