Want to use PHP to crawl a site inventory data

Source: Internet
Author: User
Want to crawl the remaining stock quantity on this site
Http://www.beibei.com/detail/105272.html
Use fopen (), and then read the source code, display the inventory amount of 0, checked the data said need to disguise HTTP, do not know how to do, online, such as Daniel ~ ~ ~


Reply to discussion (solution)

File_get_contents (); Obtain the source code and then use regular filtering.

Moderator, the amount of inventory in this method to grab is-empty

has been solved:

 
  $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 '
';p rint_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] = 458
[6] = 459
[7] = 468
)

)

[Sku_kv_map] = = Array
(
[K3] = Color
[V15] = large B Red
[V16] = large B Black
[V19] = large B Green
[V20] = large B Powder
[V22] = s Green
[v458] = s Black
[v459] = small Pink
[v468] = s RED
)

[Sku_stock_map] = = Array
(
[V15] = = Array
(
[id] = 61788
[Stock] = 100
[Price] = 9900
[Origin_price] = 21800
)

[V16] = = Array
(
[id] = 61789
[Stock] = 100
[Price] = 9900
[Origin_price] = 21800
)

[v19] = = Array
(
[id] = 61790
[Stock] = 100
[Price] = 9900
[Origin_price] = 21800
)

[V20] = = Array
(
[id] = 61791
[Stock] = 100
[Price] = 9900
[Origin_price] = 21800
)

[V22] = = Array
(
[id] = 61792
[Stock] = 100
[Price] = 8900
[Origin_price] = 19800
)

[v458] = = Array
(
[id] = 61793
[Stock] = 100
[Price] = 8900
[Origin_price] = 19800
)

[v459] = = Array
(
[id] = 61794
[Stock] = 100
[Price] = 8900
[Origin_price] = 19800
)

[v468] = = Array
(
[id] = 61795
[Stock] = 100
[Price] = 8900
[Origin_price] = 19800
)

[V0] = 800
)

)

)
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.