Search code examples
pythonhtmlxpathscrapyscreen-scraping

I want the xpath to get the all the text in <strong> tag, the problem is that there is a strong within strong tag and the i want is from both strong


The HTML code is given below, i want all the text in <p> tag including text in both <strong> tags.

<p>
      <strong>
              <strong class="location">لاہور:&nbsp;</strong>
              پاکستانی اداکار فواد خان کا کہنا ہے کہ پاکستان اور انڈیا کے درمیان سیاسی تناؤ کا اثر ان کے بالی وڈ میں موجود افراد سے تعلقات پر بالکل نہیں پڑا لیکن موجودہ صورتحال میں ساتھ کام کرنا آسان نہیں ہے۔
      </strong>
    </p>

Solution

  • Use double backslash

    //p//strong/text()