我在刮一個頁面,但是在我的內容被回顯之前,我想編輯鏈接。如何編輯href鏈接(刮板)
這樣做的最好方法是什麼?
我目前使用簡單的HTML DOM解析器:
// create HTML DOM
$html = file_get_html('http://myurl.com');
// remove all image
foreach($html->find('img') as $e)
$e->outertext = '';
foreach($html->find('font') as $e)
$e->outertext = '';
// find all td tags with attribite align=center
foreach($html->find('td[align=left]', 2) as $e)
echo $e->innertext;
有此位的其中一個網址:
<a target="retailer" href="/cgi-bin/redirect.cgi?name=Storm%20Computers&linkid=2&newurl=http%3A%2F%2Fwww.stormcomputers.com.au%2Fcatalog%2Findex.php%3FcPath%3D38_364&query=sandy%20bridge&uca=208-0-0&kwi=&rpos=2" title="Storm Computers: Click to see item">$149.00</a>
我想改變這
<a href="http%3A%2F%2Fwww.stormcomputers.com.au%2Fcatalog%2Findex.php%3FcPath%3D38_364&query=sandy%20bridge&uca=208-0-0&kwi=&rpos=2">$149.00</a>
(即剛剛在& newurl =)
謝謝。
只要你沒有注意到,你有`newulr`。 – thirtydot 2011-01-09 22:12:38
@thirtydot。感謝您指出! – PeeHaa 2011-01-09 22:14:01