Jump to content

Recommended Posts

Добрый день!

 

Автоматизируем процесс обновления остатков сайта и добавления новых товаров на основании обновляемого файла поставщика.

Встала проблема с опцией цвета.

 

Нам нужно по заданному URL (например: http://moscow.js-company.ru/catalog/kolgotki/filodoro-classic/klassika-7/ninfa-40 )
вернуть в виде массива названия и коды цветов из блока "Укажите цвет":
который имеет вид:

Спойлер
<div class="scroll-box btn-group btn-group-vertical" ng-init="colors = [{'label':'abbronzante','labels':[{'label':'abbronzante','bg':'8e7855','fg':'ffffff'}],'name':'abbronzante','value':'18','bg':'8e7855','fg':'ffffff'},{'label':'antracite fld','labels':[{'label':'antracite fld','bg':'3f4b52','fg':'ffffff'}],'name':'antracite fld','value':'24','bg':'3f4b52','fg':'ffffff'},{'label':'bronzo fld','labels':[{'label':'bronzo fld','bg':'816439','fg':'ffffff'}],'name':'bronzo fld','value':'29','bg':'816439','fg':'ffffff'},{'label':'cappuccio fld','labels':[{'label':'cappuccio fld','bg':'535031','fg':'ffffff'}],'name':'cappuccio fld','value':'5','bg':'535031','fg':'ffffff'},{'label':'cognac fld','labels':[{'label':'cognac fld','bg':'cfad84','fg':'000000'}],'name':'cognac fld','value':'6','bg':'cfad84','fg':'000000'},{'label':'glace fld','labels':[{'label':'glace fld','bg':'987f5d','fg':'000000'}],'name':'glace fld','value':'7','bg':'987f5d','fg':'000000'},{'label':'nero','labels':[{'label':'nero','bg':'000000','fg':'ffffff'}],'name':'nero','value':'2','bg':'000000','fg':'ffffff'},{'label':'noce fld','labels':[{'label':'noce fld','bg':'90704a','fg':'ffffff'}],'name':'noce fld','value':'9','bg':'90704a','fg':'ffffff'},{'label':'platino fld','labels':[{'label':'platino fld','bg':'586062','fg':'ffffff'}],'name':'platino fld','value':'26','bg':'586062','fg':'ffffff'},{'label':'playa','labels':[{'label':'playa','bg':'d9c098','fg':'000000'}],'name':'playa','value':'8','bg':'d9c098','fg':'000000'}]" ng-show="colors.length > 0"><!-- ngRepeat: color in colors --><label class="btn radio ng-scope" ng-repeat="color in colors" for="color_18" ng-disabled="hasDisabledColor(18)" ng-class="{disabled: hasDisabledColor(18)}" ng-show="availableFor('s', 18)" data-ng-unchange=""><input type="radio" class="ui-helper-hidden-accessible ng-pristine ng-untouched ng-valid" data-model="c" ng-disabled="hasDisabledColor(18)" ng-class="{unmount: hasDisabledColor(18)}" ng-model="m.c" value="18" ng-value="color.value" name="color" id="color_18" ng-change="selectItem('color', 'c', {"label":"abbronzante","labels":[{"label":"abbronzante","bg":"8e7855","fg":"ffffff"}],"name":"abbronzante","value":"18","bg":"8e7855","fg":"ffffff"})"><span class="color-box" data-product-color="color"><span class="simple ng-scope" style="background-color: #8e7855;color: #ffffff;">abbronzante</span></span></label><!-- end ngRepeat: color in colors --><label class="btn radio ng-scope" ng-repeat="color in colors" for="color_24" ng-disabled="hasDisabledColor(24)" ng-class="{disabled: hasDisabledColor(24)}" ng-show="availableFor('s', 24)" data-ng-unchange=""><input type="radio" class="ui-helper-hidden-accessible ng-pristine ng-untouched ng-valid" data-model="c" ng-disabled="hasDisabledColor(24)" ng-class="{unmount: hasDisabledColor(24)}" ng-model="m.c" value="24" ng-value="color.value" name="color" id="color_24" ng-change="selectItem('color', 'c', {"label":"antracite fld","labels":[{"label":"antracite fld","bg":"3f4b52","fg":"ffffff"}],"name":"antracite fld","value":"24","bg":"3f4b52","fg":"ffffff"})"><span class="color-box" data-product-color="color"><span class="simple ng-scope" style="background-color: #3f4b52;color: #ffffff;">antracite fld</span></span></label><!-- end ngRepeat: color in colors --><label class="btn radio ng-scope disabled" ng-repeat="color in colors" for="color_29" ng-disabled="hasDisabledColor(29)" ng-class="{disabled: hasDisabledColor(29)}" ng-show="availableFor('s', 29)" data-ng-unchange="" disabled="disabled"><input type="radio" class="ui-helper-hidden-accessible ng-pristine ng-untouched ng-valid unmount" data-model="c" ng-disabled="hasDisabledColor(29)" ng-class="{unmount: hasDisabledColor(29)}" ng-model="m.c" value="29" ng-value="color.value" name="color" id="color_29" ng-change="selectItem('color', 'c', {"label":"bronzo fld","labels":[{"label":"bronzo fld","bg":"816439","fg":"ffffff"}],"name":"bronzo fld","value":"29","bg":"816439","fg":"ffffff"})" disabled="disabled"><span class="color-box" data-product-color="color"><span class="simple ng-scope" style="background-color: #816439;color: #ffffff;">bronzo fld</span></span></label><!-- end ngRepeat: color in colors --><label class="btn radio ng-scope" ng-repeat="color in colors" for="color_5" ng-disabled="hasDisabledColor(5)" ng-class="{disabled: hasDisabledColor(5)}" ng-show="availableFor('s', 5)" data-ng-unchange=""><input type="radio" class="ui-helper-hidden-accessible ng-pristine ng-untouched ng-valid" data-model="c" ng-disabled="hasDisabledColor(5)" ng-class="{unmount: hasDisabledColor(5)}" ng-model="m.c" value="5" ng-value="color.value" name="color" id="color_5" ng-change="selectItem('color', 'c', {"label":"cappuccio fld","labels":[{"label":"cappuccio fld","bg":"535031","fg":"ffffff"}],"name":"cappuccio fld","value":"5","bg":"535031","fg":"ffffff"})"><span class="color-box" data-product-color="color"><span class="simple ng-scope" style="background-color: #535031;color: #ffffff;">cappuccio fld</span></span></label><!-- end ngRepeat: color in colors --><label class="btn radio ng-scope" ng-repeat="color in colors" for="color_6" ng-disabled="hasDisabledColor(6)" ng-class="{disabled: hasDisabledColor(6)}" ng-show="availableFor('s', 6)" data-ng-unchange=""><input type="radio" class="ui-helper-hidden-accessible ng-pristine ng-untouched ng-valid" data-model="c" ng-disabled="hasDisabledColor(6)" ng-class="{unmount: hasDisabledColor(6)}" ng-model="m.c" value="6" ng-value="color.value" name="color" id="color_6" ng-change="selectItem('color', 'c', {"label":"cognac fld","labels":[{"label":"cognac fld","bg":"cfad84","fg":"000000"}],"name":"cognac fld","value":"6","bg":"cfad84","fg":"000000"})"><span class="color-box" data-product-color="color"><span class="simple ng-scope" style="background-color: #cfad84;color: #000000;">cognac fld</span></span></label><!-- end ngRepeat: color in colors --><label class="btn radio ng-scope" ng-repeat="color in colors" for="color_7" ng-disabled="hasDisabledColor(7)" ng-class="{disabled: hasDisabledColor(7)}" ng-show="availableFor('s', 7)" data-ng-unchange=""><input type="radio" class="ui-helper-hidden-accessible ng-pristine ng-untouched ng-valid" data-model="c" ng-disabled="hasDisabledColor(7)" ng-class="{unmount: hasDisabledColor(7)}" ng-model="m.c" value="7" ng-value="color.value" name="color" id="color_7" ng-change="selectItem('color', 'c', {"label":"glace fld","labels":[{"label":"glace fld","bg":"987f5d","fg":"000000"}],"name":"glace fld","value":"7","bg":"987f5d","fg":"000000"})"><span class="color-box" data-product-color="color"><span class="simple ng-scope" style="background-color: #987f5d;color: #000000;">glace fld</span></span></label><!-- end ngRepeat: color in colors --><label class="btn radio ng-scope" ng-repeat="color in colors" for="color_2" ng-disabled="hasDisabledColor(2)" ng-class="{disabled: hasDisabledColor(2)}" ng-show="availableFor('s', 2)" data-ng-unchange=""><input type="radio" class="ui-helper-hidden-accessible ng-pristine ng-untouched ng-valid" data-model="c" ng-disabled="hasDisabledColor(2)" ng-class="{unmount: hasDisabledColor(2)}" ng-model="m.c" value="2" ng-value="color.value" name="color" id="color_2" ng-change="selectItem('color', 'c', {"label":"nero","labels":[{"label":"nero","bg":"000000","fg":"ffffff"}],"name":"nero","value":"2","bg":"000000","fg":"ffffff"})"><span class="color-box" data-product-color="color"><span class="simple ng-scope" style="background-color: #000000;color: #ffffff;">nero</span></span></label><!-- end ngRepeat: color in colors --><label class="btn radio ng-scope disabled" ng-repeat="color in colors" for="color_9" ng-disabled="hasDisabledColor(9)" ng-class="{disabled: hasDisabledColor(9)}" ng-show="availableFor('s', 9)" data-ng-unchange="" disabled="disabled"><input type="radio" class="ui-helper-hidden-accessible ng-pristine ng-untouched ng-valid unmount" data-model="c" ng-disabled="hasDisabledColor(9)" ng-class="{unmount: hasDisabledColor(9)}" ng-model="m.c" value="9" ng-value="color.value" name="color" id="color_9" ng-change="selectItem('color', 'c', {"label":"noce fld","labels":[{"label":"noce fld","bg":"90704a","fg":"ffffff"}],"name":"noce fld","value":"9","bg":"90704a","fg":"ffffff"})" disabled="disabled"><span class="color-box" data-product-color="color"><span class="simple ng-scope" style="background-color: #90704a;color: #ffffff;">noce fld</span></span></label><!-- end ngRepeat: color in colors --><label class="btn radio ng-scope" ng-repeat="color in colors" for="color_26" ng-disabled="hasDisabledColor(26)" ng-class="{disabled: hasDisabledColor(26)}" ng-show="availableFor('s', 26)" data-ng-unchange=""><input type="radio" class="ui-helper-hidden-accessible ng-pristine ng-untouched ng-valid" data-model="c" ng-disabled="hasDisabledColor(26)" ng-class="{unmount: hasDisabledColor(26)}" ng-model="m.c" value="26" ng-value="color.value" name="color" id="color_26" ng-change="selectItem('color', 'c', {"label":"platino fld","labels":[{"label":"platino fld","bg":"586062","fg":"ffffff"}],"name":"platino fld","value":"26","bg":"586062","fg":"ffffff"})"><span class="color-box" data-product-color="color"><span class="simple ng-scope" style="background-color: #586062;color: #ffffff;">platino fld</span></span></label><!-- end ngRepeat: color in colors --><label class="btn radio ng-scope" ng-repeat="color in colors" for="color_8" ng-disabled="hasDisabledColor(8)" ng-class="{disabled: hasDisabledColor(8)}" ng-show="availableFor('s', 8)" data-ng-unchange=""><input type="radio" class="ui-helper-hidden-accessible ng-pristine ng-untouched ng-valid" data-model="c" ng-disabled="hasDisabledColor(8)" ng-class="{unmount: hasDisabledColor(8)}" ng-model="m.c" value="8" ng-value="color.value" name="color" id="color_8" ng-change="selectItem('color', 'c', {"label":"playa","labels":[{"label":"playa","bg":"d9c098","fg":"000000"}],"name":"playa","value":"8","bg":"d9c098","fg":"000000"})"><span class="color-box" data-product-color="color"><span class="simple ng-scope" style="background-color: #d9c098;color: #000000;">playa</span></span></label><!-- end ngRepeat: color in colors --></div>


 


функция парсинга должна вернуть массив цветов $colors, где каждый элемент массива имеет следующие ключи как в примере

'name':'abbronzante','value':'18','bg':'8e7855','fg':'ffffff'


 

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×

Important Information

On our site, cookies are used and personal data is processed to improve the user interface. To find out what and what personal data we are processing, please go to the link. If you click "I agree," it means that you understand and accept all the conditions specified in this Privacy Notice.