How to handle dynamic changing ID's In XPath?

vldsam95

Power Member
Joined
May 27, 2018
Messages
583
Reaction score
43
i have some part of the page that i want to scrap in screaming frog

i use extraction function
i found the xpath of what i want
it is:
//*[@id="post-742"]

but now i want to scrape and extract that part from all the posts
the post number is different in every post

what i need to wright instead of the post number (how i can make a dynamic number)
 
show more page html piece of content (or pastebin somehow), there are always couple ways how to scrape, for example forEach through some parent element of each post
 
Use contains() or starts-with() XPath function and loop through results:

//div[contains(@id,'post-')]

//div[starts-with(@id,'post-')]
 
i = somenumber
//*[@id="post-" 'i ""]
i = i + 1
you can make a loop that will loop the post ids
this only works if the post id is incremented by 1 each time otherwise the answer above is your answer
 
Back
Top