Advertisement
ilools

Untitled

Feb 19th, 2014
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. <?php
  2. header("Content-Type:text/html;charset=UTF-8");
  3.  
  4. function get_curl_contents($url) {
  5. $user_agent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.69 Safari/537.36";
  6. $referer = "http://item.jd.com/986323.html#none/";
  7. $ch = curl_init();
  8. $timeout = 30;
  9. curl_setopt($ch, CURLOPT_URL, $url);
  10. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  11. curl_setopt($ch, CURLOPT_REFERER, $referer);
  12. curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
  13. curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
  14. $data = curl_exec($ch);
  15. curl_close($ch);
  16.  
  17. return $data;
  18. }
  19.  
  20. $url = 'http://st.3.cn/gds.html?callback=getStockCallback&skuid=7FE79285FC5FF87B3BD5E7A34C6FFCC1&provinceid=21&cityid=1898&areaid=1907&townid=0&sortid1=670&sortid2=677&sortid3=679';
  21.  
  22. $content=get_curl_contents($url);
  23. //echo $content;
  24. preg_match("|StockStateName\":\"([\s\S]*?)\"|",$content,$data);
  25. $datas = iconv('GBK', 'UTF-8', $data[1]);
  26. if($datas == "有货")
  27.  
  28. {
  29. curl_setopt_array($ch = curl_init(), array(
  30. CURLOPT_URL => "https://api.pushover.net/1/messages.json",
  31. CURLOPT_POSTFIELDS => array(
  32. "token" => "xxxxx",
  33. "user" => "xxxxxx",
  34. "message" => "270X 有货",
  35. )));
  36. curl_exec($ch);
  37. curl_close($ch);
  38.  
  39. }
  40. //echo $pr[1];
  41. else{
  42.  
  43. echo '<h1>还是没货 30 seconds later auto load !</h1>
  44. <head>
  45. <meta http-equiv="refresh" content="30;url=ffff.php">
  46. </head>';
  47. }
  48.  
  49. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement