2016-12-30 49 views
0

我要如何scrapp數據從這個url從阿賈克斯或者JSON

我能夠從HTML標籤usign捲曲取簡單的數據,但不能從JSON或阿賈克斯獲取數據報廢的數據,我不知道它是Ajax還是Json數據。

在以下屏幕快照中,我想獲取設備型號數據enter image description here

哪個來的形式我想json或ajax。這裏下面== >>

enter image description here

是我的腳本,從頁面獲取數據 -

$loginURL = "https://www.apwagner.com/appliance-part/wpl/wp661600"; 
//$file='source.html'; //create a html file to save source code 
    $ch = curl_init(); 
    $timeout = 5; 
    curl_setopt($ch, CURLOPT_URL, $loginURL); 
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); 
    $data = curl_exec($ch); 
    curl_close($ch); 

請提供一些指導,以獲取此信息..

$ch = curl_init(); 

curl_setopt($ch, CURLOPT_URL,"https://www.apwagner.com/Product/GetPartModel"); 
curl_setopt($ch, CURLOPT_POST, 1); 
curl_setopt($ch, CURLOPT_POSTFIELDS, 
      "partNumber=wp661600&make=wpl"); 

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 

$server_output = curl_exec ($ch); 

curl_close ($ch); 
+0

報廢數據有你看着' DOMDocument'? http://php.net/manual/en/domdocument.loadhtml.php –

+0

是的,我也檢查過。但沒有奏效。 – Nikita

+0

顯然,不會直接工作,這只是爲了幫助你開始啓動..你將不得不根據你的要求創建一個代碼... –

回答

1

的一部分的數據頁面通過ajax請求。

see this screenshot

你需要你的第一卷曲響應後的捲曲度 做收到

$ch = curl_init(); 

curl_setopt($ch, CURLOPT_URL,"https://www.apwagner.com/Product/GetPartModel"); 
curl_setopt($ch, CURLOPT_POST, 1); 
curl_setopt($ch, CURLOPT_POSTFIELDS, 
      "partNumber=wp661600&make=wpl"); 

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 

$server_output = curl_exec ($ch); 

curl_close ($ch); 

,或者嘗試使用python腳本

import string 
import time 
from selenium import webdriver 

driver = webdriver.Chrome('<path to your chrome driver>') 
driver.get('https://www.apwagner.com/appliance-part/wpl/wp661600');