is there a way in puppeteer to get the href attribute of an anchor element with text "See more".
I want to grab the href attribute of an element like this:
<a href="/this-is-what-i-want">See more</a>
maybe it's possble to do with eval?
is there a way in puppeteer to get the href attribute of an anchor element with text "See more".
I want to grab the href attribute of an element like this:
<a href="/this-is-what-i-want">See more</a>
maybe it's possble to do with eval?
you could try looping through all links
document.querySelectorAll('a').forEach(link => link.innerText === "See more" )
This might not work with newer JavaScript versions since querySelectorAll
as well as getElementsByTagName
do not yield an Array but HTMLCollection
which is not iterable using forEach
. See the linked answers on SO on how to fix this.
maybe you should try native js
url=document.getElementById("Id_of_AnchorTag").href;
keep in mind that you must be able to uniquely identify the anchor by some method.