I want to use PHP to capture the inventory data of a website. I want to capture the remaining inventory quantity of this website.
Http://www.beibei.com/detail/105272.html
When fopen () is used, and then the source code is read, the inventory displayed is 0. I checked the information and said that I needed to pretend to be HTTP. I don't know how to get it. I am online and so on ~~~
Reply to discussion (solution)
File_get_contents (); obtain the source code and use regular expression filtering.
The inventory in the moderator is captured in this way-empty ·····
Resolved:
$ Hxcsrf, 'id' => $ id); $ opts = array ('http' => array ('method' => 'post ', 'header' => 'Content-type: application/x-www-form-urlencoded', 'content' => $ postdata); $ context = stream_context_create ($ opts ); $ sku = file_get_contents ($ skuapi, false, $ context); $ result = json_decode ($ sku, true); echo'
'; Echo'';print_r($result);echo '
';?>
Array
(
[Success] => 1
[Data] => Array
(
[Sku_id_map] => Array
(
[3] => Array
(
[0] => 15
[1] => 16
[2] => 19
[3] => 20
[4] => 22
[5] = & gt; 458
[6] = & gt; 459
[7] = & gt; 468
)
)
[Sku_kv_map] => Array
(
[K3] => color
[V15] => Large B Red
[V16] => Large B Black
[V19] => Large B Green
[V20] => Large bits
[V22] => small green
[V458] => small black
[V459] => small pink
[V468] => small red
)
[Sku_stock_map] => Array
(
[V15] => Array
(
[Id] = & gt; 61788
[Stock] = & gt; 100
[Price] = & gt; 9900
[Origin_price] = & gt; 21800
)
[V16] => Array
(
[Id] = & gt; 61789
[Stock] = & gt; 100
[Price] = & gt; 9900
[Origin_price] = & gt; 21800
)
[V19] => Array
(
[Id] = & gt; 61790
[Stock] = & gt; 100
[Price] = & gt; 9900
[Origin_price] = & gt; 21800
)
[V20] => Array
(
[Id] = & gt; 61791
[Stock] = & gt; 100
[Price] = & gt; 9900
[Origin_price] = & gt; 21800
)
[V22] => Array
(
[Id] = & gt; 61792
[Stock] = & gt; 100
[Price] = & gt; 8900
[Origin_price] = & gt; 19800
)
[V458] => Array
(
[Id] = & gt; 61793
[Stock] = & gt; 100
[Price] = & gt; 8900
[Origin_price] = & gt; 19800
)
[V459] => Array
(
[Id] = & gt; 61794
[Stock] = & gt; 100
[Price] = & gt; 8900
[Origin_price] = & gt; 19800
)
[V468] => Array
(
[Id] = & gt; 61795
[Stock] = & gt; 100
[Price] = & gt; 8900
[Origin_price] = & gt; 19800
)
[V0] = & gt; 800
)
)
)