2011-07-25 53 views
1

我想從不同網站獲取靜態數據(提供的URL和元素名稱),最簡單的方法是什麼?從不同網站獲取數據的最簡單方法

www.address /用品/抓鬥該

<html> 
    (...) 
    <article id="#article-121"> 
    <h1>Header</h1> 
    <p>Contents</p> 
    </article> 
    (...) 
</html> 

的index.php

/* Grab "#article-121" from www.address/articles/grab-this */ 

    <article id="#article-121"> 
     <h1>Header</h1> 
     <p>Contents</p> 
    </article> 

/* Close the connection */ 
+0

重複搜索解析HTML的PHP​​ – dynamic

+0

的具體實施方法,可能重複解析HTML與PHP](http://stackoverflow.com/questions/3577641/best-methods-to-parse-html-with-php) – Gordon

回答

2
$contents = file_get_contents(url_goes_here); 
+0

這是一個很好的答案,但我想基於ID獲取確切的元素要困難得多嗎? – Wordpressor

+0

是的,那是真的。一旦你擁有'$ contents',你應該可以操縱/解析它 – Eruant

相關問題