2016-03-29 13 views
0

私は、巨大なカントリー・ワイド・カー・セールス・ウェブサイトに彼の取引を置き、同社のウェブサイトで同じ自動車取引をしたいと思う自動車販売店のための個人用ウェブサイトを作っています。ダブル提出を避けるために、私はthe country wide websiteから車の情報を取り出し、会社のウェブサイトに入れることに決めました。情報をWordPressに盗む

当社のウェブサイトはWordpressで作成されています。 私はPHPにあまり慣れていません。

この種の作業のためのプラグインはありますか? 私はnode.jsのようなものを使ってこれを達成できたのでしょうか?

私はプロセスがこのように見えると想像します: 新型車があればスクリプトは主な国のワイドウェブサイトをスキャンして開き、内部の情報を読んで会社のウェブサイトに情報を入れます表示されます。

+1

[curl](http://php.net/manual/en/book.curl.php)と[DOMDocument](http://php.net/manual/en/class.domdocument.php)が必要です。ソースサイトには便利なAPIがあります。 – DevDonkey

答えて

0

はこれを見てい:あなたのケースのget_html_table( 'http://auto.plius.lt/litechnija/skelbimai/zemes-ukio-misko-technika-manipuliatoriai/zemes-ukio-savaeige-technika'、 'DIV'、 'アイテム')で

function get_inner_html($node) { 
    $innerHTML= ''; 
    $children = $node->childNodes; 
    foreach ($children as $child) { 
     $innerHTML .= $child->ownerDocument->saveXML($child); 
    } 

    return $innerHTML; 
} 
function get_html_table($link,$element,$class){ 
//$data=date("Y-m-d"); 
$html = file_get_contents($link); //get the html returned from the following url 
$poke_doc = new DOMDocument(); 
libxml_use_internal_errors(false); //disable libxml errors 
libxml_use_internal_errors(true); 
if(!empty($html)){ //if any html is actually returned 
    $poke_doc->loadHTML($html); 
    libxml_clear_errors(); //remove errors for yucky html 
    $poke_xpath = new DOMXPath($poke_doc); 
    $poke_type = $poke_xpath->query("//".$element."[@class='".$class."']"); 
    $table = "<table>"; 
    foreach($poke_type as $type){ 
     $table .= get_inner_html($type); 
    } 
    $table .= "</table>"; 
return $table; 
} 

echo get_html_table('https://www.linkname.com','div','kv'); 
//fist parameter the link; second: the dom element you want to scrap; third the class of the element 

を。

+0

後でありがとう:) – SnakeFoot

関連する問題