$urls = "//c.tb.cn/h.eoEsT08?sm=d79c3c";
$chss = curl_init(); curl_setopt($chss, CURLOPT_URL, $urls);curl_setopt($chss, CURLOPT_RETURNTRANSFER, 1);curl_setopt($chss, CURLOPT_FOLLOWLOCATION,true);curl_setopt($chss, CURLOPT_MAXREDIRS,2);curl_setopt($chss, CURLOPT_SSL_VERIFYPEER, FALSE);curl_setopt($chss, CURLOPT_SSL_VERIFYHOST, FALSE);$contents = curl_exec($chss);curl_close($chss);$item_url = get_word($contents,"var url = '", "';");echo $item_url;
自舉例抓取指數函數function get_word($html,$star,$end){$pat = '/'.$star.'(.*?)'.$end.'/s';if(!preg_match_all($pat, $html, $mat)) { }else{$wd= $mat[1][0];}return $wd;}
最后打印出來://a.m.taobao.com/i587155350398.htm?price=59&sourceType=item&sourceType=item&suid=16444eb8-5c8e-45f8-8a2f-029c43d40f05&ut_sk=1.XCv%2FCA9ynMADABVsYdOVFY5s_21646297_1570646701538.Copy.1&un=61f102dac9fc08ff4b68d5f77a161062&share_crt_v=1&spm=a2159r.13376460.0.0&sp_tk=JEF3MXZZTG9UZFVVJA==&cpp=1&shareurl=true&short_name=h.eoEsT08
觀察到商品是地址也沒有?