Complete newbie with this, so appreciate advice.
I know how to get a tag's contents if it has a unique id, but many websites are like the following, where I want the content of a tag following another tag with a specific String as the content.
Is there a way to try to do a conditional expression OR extract the entire section and run regex OR a better way?
Thanks!
In Example 1, I want "May 11, 2021" which follows the following tags:
<div class="a-section a-spacing-small a-text-center rpi-attribute-label">
<span>Publication date</span>
</div>
<div class="a-section a-spacing-small a-text-center">
<span class="rpi-icon book_details-publication_date"></span>
</div>
In Example 2, I want "September 7, 2021"
Example 1:
<li class="a-carousel-card rpi-carousel-attribute-card" role="listitem" aria posinset="3">
<div class="a-section rpi-attribute-content">
<div class="a-section a-spacing-small a-text-center rpi-attribute-label">
<span>Publication date</span>
</div>
<div class="a-section a-spacing-small a-text-center">
<span class="rpi-icon book_details-publication_date"></span>
</div>
<div class="a-section a-spacing-none a-text-center rpi-attribute-value">
<span>May 11, 2021</span>
</div>
</div>
</li>
Example 2:
<li><span class="a-list-item">
<span class="a-text-bold">Publication date
‏
:
‎
</span>
<span>September 7, 2021</span>
</span></li>
Example #1, try this xpath
"//div[@class='a-section a-spacing-none a-text-center rpi-attribute-value']/span"
Example #2
"//span[@class='a-list-item']/span[2]"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.