Xpath. Помогите составить!

Поддержка
  • Доброго дня!
    Помогите пожалуйста составить xpath запрос, чтобы извлечь все Артикулы из вот такого массива

    <param type="JSON" name="category"
                   get-dom-data="catalog.list"
                   catalog-brand="catalog.brand"
                   data-categoryid="162"
                   category-id="catalog.categoryId"
                   value="{&quot;417694&quot;:{&quot;sku&quot;:&quot;417694&quot;,&quot;id&quot;:58234,&quot;shortName&quot;:&quot;&quot;,&quot;options&quot;:{&quot;name&quot;:&quot;Пенка для умывания увлажняющая, 150 мл&quot;,&quot;price&quot;:{&quot;value&quot;:950,&quot;currency&quot;:{&quot;externalIso&quot;:&quot;RSD&quot;,&quot;logo&quot;:&quot;дин.&quot;,&quot;decimals&quot;:2,&quot;decimalPoint&quot;:&quot;.&quot;,&quot;thousandSeparator&quot;:&quot; &quot;,&quot;isPrefixed&quot;:false,&quot;roundRules&quot;:0.01}},&quot;newPrice&quot;:null,&quot;points&quot;:9,&quot;markers&quot;:[],&quot;pricePer100Units&quot;:{&quot;value&quot;:633.33,&quot;currency&quot;:{&quot;externalIso&quot;:&quot;RSD&quot;,&quot;logo&quot;:&quot;дин.&quot;,&quot;decimals&quot;:2,&quot;decimalPoint&quot;:&quot;.&quot;,&quot;thousandSeparator&quot;:&quot; &quot;,&quot;isPrefixed&quot;:false,&quot;roundRules&quot;:0.01}},&quot;unit&quot;:&quot;ml&quot;,&quot;vatIndex&quot;:20,&quot;expirationDate&quot;:&quot;01.09.2022&quot;,&quot;sortIndex&quot;:0,&quot;vat&quot;:190,&quot;volume&quot;:null,&quot;attributes&quot;:[{&quot;id&quot;:&quot;182&quot;,&quot;type&quot;:&quot;Объем&quot;,&quot;value&quot;:&quot;150 мл \/ 5.28 fl oz&quot;}]},&quot;categories&quot;:[{&quot;id&quot;:3,&quot;name&quot;:&quot;Косметика&quot;,&quot;showInMobile&quot;:true},{&quot;id&quot;:162,&quot;name&quot;:&quot;Очищение для лица&quot;,&quot;showInMobile&quot;:true},{&quot;id&quot;:311,&quot;name&quot;:&quot;Косметика с комплексом ENDEMIX™&quot;,&quot;showInMobile&quot;:true}],&quot;brief&quot;:&quot;&quot;,&quot;showBrief&quot;:false,&quot;isArchived&quot;:false,&quot;thumbnails&quot;:&quot;https:\/\/static.siberianhealth.com\/public\/projects\/shopen\/images\/41\/_resize\/417694_14abcd3f_fit_300_300.png.webp&quot;,&quot;topCategory&quot;:{&quot;id&quot;:3,&quot;name&quot;:&quot;Косметика&quot;},&quot;isDemandForbidden&quot;:true,&quot;isUsedInAction&quot;:false}
    

    Артикулы имеется ввиду именно те, что обозначаются как "417694" и т.д.:

    sku&quot;:&quot;417694&quot;
    

    И возможно ли такое сделать?

    Причем если делать через Веб, все отлично парсится. А на запросах не получается разобраться с таким кодом((

    Буду признателен за помощь!

  • @Ivserzh12 у вас некорректный текст, он не весь, поэтому работоспособность не ручаюсь.

    //param[@type and @name and @value]

    если в браузере то получить атрибут элемента value
    если код уже есть в переменной xpath кубик //param[@type and @name and @value]/@value получить xml. Это JSON формат &quot; это спец символы их не будет, (это " в браузере ) полученный xml парсите.
    У вас не весь код приходится додумывать что там должно быть

  • @lotra В браузере xpath по классу находит без проблем.
    Хотел, через GET-запрос сделать, но по классу, которому находит через браузер, выдает пустоту... В SAVED_CONTENT портянка того кода, что выкладывал выше (да, только его часть, потому что он огромный).

    Спасибо за вариант, попробую применить!

  • If Xpath works in the browser it should work the same via GET request.

    However, maybe you are mixing GET requests and browser version in your
    test code. That results in empty value when you send Xpath query through
    GET request.

    The point of using GET requests is to save usage of hard disc and RAM space, So get
    request is saved only in RAM memory and that is the reason why it works
    faster and saves hard disk and RAM space too,

    Once you send GET request you have to follow it with Xpath GET request.
    If you use SAVED CONTENT between you will loose initial GET request and
    Xpath get request will return empty string because it no longer works with
    last sent GET request, since you interrupted it with "SAVED CONTENT".

    Im not sure that this apply to your case, since you did not provide a test code.
    But it might be possible that you are actually mixing GET requests and
    "SAVED CONTENT" - so its not working as expected

    If you work with GET requests, there is no point of using "SAVED CONTENT" since
    "SAVED CONTENT" is usually used for saving data to hard disc and breaks last GET
    request. So if you work with GET requests do not mix them with browser actions like "SAVED CONTENT"..

  • 0 Votes
    8 Posts
    628 Views
  • 0 Votes
    2 Posts
    367 Views
  • 0 Votes
    2 Posts
    426 Views
  • 0 Votes
    2 Posts
    435 Views
  • 1 Votes
    21 Posts
    4701 Views