Esempio n. 1
0
curl_setopt($ch, CURLOPT_POSTFIELDS, $postinfo);
curl_exec($ch);
// Login section end.
// TODO ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ -- -- - - -
$file = file_get_contents('categories.json');
$data = json_decode($file);
$categoriesData = array();
foreach ($data as $link) {
    $catLink = parse_url($link);
    parse_str($catLink['query'], $catParams);
    if (!empty($catParams['cID'])) {
        $categoriesData[] = parseCategoryData($ch, $link . '&action=edit_category', $catParams);
    }
}
if (count($categoriesData)) {
    saveAsCsv(array_keys($categoriesData[0]), $categoriesData, 'categories.csv');
}
echo '<pre>';
print_r($categoriesData);
echo '</pre>';
curl_close($ch);
function parseCategoryData($curl, $url, $catIds)
{
    curl_setopt($curl, CURLOPT_URL, $url);
    $output = curl_exec($curl);
    $result = array();
    $categoryDom = str_get_html($output);
    $catData = $categoryDom->find('form[name="categories"]', 0);
    /**
     * 0 -> Text notice
     * 1 -> Category name
Esempio n. 2
0
        $lastPage = $pages->value;
    }
    if ($lastPage < $page) {
        $page = 0;
    }
}
$customersData = array();
if (count($customerLinks)) {
    foreach ($customerLinks as $link) {
        curl_setopt($ch, CURLOPT_URL, $link);
        $output = curl_exec($ch);
        $customer = str_get_html($output);
        $data = array();
        foreach ($customer->find('input') as $element) {
            if ($key = $element->attr['name']) {
                $value = $element->attr['value'];
                $data[$key] = $value;
            }
        }
        $data['entry_country_id'] = $customer->find('select[name="entry_country_id"]', 0)->find('option[selected=""]', 0)->innertext;
        $customersData[] = $data;
    }
}
if (count($customersData)) {
    saveAsCsv(array_keys($customersData[0]), $customersData, 'customers.csv');
}
echo '<pre>';
print_r($customerLinks);
echo '</pre>';
// Customer export section end.
curl_close($ch);
Esempio n. 3
0
curl_exec($ch);
// Login section end.
// TODO ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ -- -- - - -
$file = file_get_contents('products.json');
//$file = file_get_contents('test.json');
$data = json_decode($file);
// TODO REMOVE
echo count($data);
$productsData = array();
foreach ($data as $link) {
    $productLink = parse_url($link);
    parse_str($productLink['query'], $prodParams);
    $productsData[] = parseCategoryData($ch, $link . '&action=new_product', $prodParams);
}
if (count($productsData)) {
    saveAsCsv(array_keys($productsData[0]), $productsData, 'products.csv');
}
curl_close($ch);
function parseCategoryData($curl, $url, $prodIds)
{
    // TODO log product
    logData($url . PHP_EOL);
    curl_setopt($curl, CURLOPT_URL, $url);
    $output = curl_exec($curl);
    $result = array();
    $productDom = str_get_html($output);
    // TODO here starts the product content
    $prodData = $productDom->find('form[name="new_product"]', 0);
    $prodElem = $prodData->find('tr', 3);
    $result['sku'] = $prodElem->find('input[name="products_model"]', 0)->value;
    $result['product_name'] = $prodElem->find('input[name="products_name[4]"]', 0)->value;