2014-02-08 27 views
0

我想撿起這個標籤由simple_dom_html我怎樣才能標籤根據屬性

$html = file_get_html($url); 

我能拿到冠軍是這樣。

$title = $html->find('title',0)->plaintext; 

但是我怎樣才能得到物品取決於財產?

<head> 
<title>test</title> 
<meta property="og:image:width" content="480"> 
<meta property="og:image:height" content="360"> 
<meta property="og:description" content=""> 
<meta property="og:image" content="http://www.mysite.com/test.jpg"> 
</head> 
+0

你是什麼意思是「我怎樣才能根據物業項目「 好,我知道了! –

回答

1

使用簡單的DOM HTML,你可以做這樣的事情:

$html = file_get_html($url); 

$m = $html->find("meta[property=og:image:width]"); //selects meta tag(s) where property=og:image:width 

$m2 = $html->find("meta[content=360]"); //selects meta tag(s) where content=360 
+0

謝謝,它完美的作品! – whitebear