puphpeteer
puphpeteer copied to clipboard
Xpath + evaluate problem. puppeteer -> puphpeteer conversion help.
Hi!
I need some help. I really can't comprehend how to convert this to puphpeteer version:
const linkToNewest = await page.evaluate(el => el.href, (await page.$x("//a[text()='thislink'][1]"))[0]);
Basically I'm trying to get href from a link that has a text "thislink".
Thank you in advance.
To answer to my own question and help someone in need.
$a = $page->querySelectorXPath("//a[text()='thislink'][1]")[0];
$b = $a->evaluate(JsFunction::createWithParameters(['el'])->body("return el.href"));
Thanks a lot man. This library has got awful documentation.
I agree but at least he put in the work to make it possible, we should contribute! great add by the way!