Take a picture first.
Implementation principle
Read the data, write the corresponding segment of the CSV line with the data segment, then save as a CSV, in the latest version of the Taobao Helper test through the
Implementation code
Copy Code code as follows:
function Totaobao ()
{
Load the selected item
$map [' goods_id '] = Array (' In ', $this->returnid ());
$result = $this->showgoods ($map);
Write CSV and save data
$header =iconv (' UTF-8 ', ' GB2312 ', "Baby name, baby category, shop category, new and old degree, province, city, Sale way, baby price, fare increase, baby quantity, validity, freight commitment, flat mail, EMS, Express, payment method, Alipay, invoice, warranty , automatic re-hair, put into the warehouse, window recommended, start time, mood story, baby description, baby picture, baby attributes, group purchase price, minimum number of items, postage template ID, member discount, modification time, upload status, picture status, rebate ratio, new picture, video, sales attribute combination, user input ID string, User input name-value pair, merchant code, sales attribute alias, charger type, baby number ");
Header ("Content-type:text/csv");
Header ("Content-disposition:attachment;filename=ybkgoods.csv");
Header (' cache-control:must-revalidate,post-check=0,pre-check=0 ');
Header (' expires:0 ');
Header (' Pragma:public ');
echo "$header \ n";
Output Data body
foreach ($result as $value)
{
Filter description fields
$desc = Csvdatafilter ("www.yibaikuan.com", $value [' Goods_desc ']);
Intercepting picture file names
$img = Msubstr ($value [' Goods_thumb '],24,25);
Escape
$body =iconv (' UTF-8 ', ' GB2312 ', $value [' Goods_name ']. ",,, 0, Zhejiang, Jinhua, B,". $value [' Shop_price ']. ", 0,". $value [' Goods_ Number ']. ", 14,1,20,20,10,,, 0,0,1,0,1,,,". $desc. ",,,,, 0,0,,100,,0," $img. ": 0:0:|;,,,,,,, 0,");
echo "$body \ n";
}
}
Need to pay attention to a few
1. Coding problems
2. The HTML code filtering problem in the product description
3. Note the path of the picture
Conclusion:
Taobao, Pat, have AH helper generated by the principle of the CSV is similar, there is a need to test.