title: Web scraping xpath
body: <p>I am trying to learn how to extract some data from web pages. I use the following code:</p>
  
  <pre><code>import requests
  from lxml import html
  
  url = 'https://www.otomoto.pl/oferta/mercedes-benz-klasa-s-s500-long-4matik-amg-ID6yEJqd.html#003d4d5f4e'
  page = requests.get(url)
  tree = html.fromstring(page.content)
  
  data1 = tree.xpath('//div[@class="offer-params__value"]/text()')
  headers= tree.xpath('//span[@class="offer-params__label"]/text()')
  data2 = tree.xpath('//a[@class="offer-params__link"]/text()')
  </code></pre>
  
  <p>Part of web page with details about car (under the picture), there are many segments <code>li</code> with car info:</p>
  
  <pre><code>&lt;li class="offer-params__item"&gt;
      &lt;span class="offer-params__label"&gt;Rok produkcji&lt;/span&gt;
      &lt;div class="offer-params__value"&gt;                1985         &lt;/div&gt;
  &lt;/li&gt;
  </code></pre>
  
  <p><a href="https://www.otomoto.pl/oferta/mercedes-benz-w201-190-190-d-ID6yLUAR.html#xtor=SEC-8" rel="nofollow noreferrer">https://www.otomoto.pl/oferta/mercedes-benz-w201-190-190-d-ID6yLUAR.html#xtor=SEC-8</a></p>
  
  <p>Is there any way to extract only one value (in this case year 1985) that is strictly associated with label for it "Rok produkcji" and both are inside only one <code>&lt;li&gt;</code>? With my code I extract list of all car details and I see no direct correlation that for example take every second item or similiar, to be sure I always get this exact thing (in this case it is manufacturing date). Would be no problem if this list length would always be the same, but it changes. And data lists are separate, depeding if they are text or link.</p>
  
  <p>Btw, if you could have some advices concerning web scraping, I would be glad to hear them. I am trying to learn Python and I am basically in the beginning.</p>