puphpeteer icon indicating copy to clipboard operation
puphpeteer copied to clipboard

Xpath + evaluate problem. puppeteer -> puphpeteer conversion help.

Open ontelo opened this issue 3 years ago • 3 comments

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.

ontelo avatar Mar 19 '21 11:03 ontelo

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"));

ontelo avatar Mar 19 '21 12:03 ontelo

Thanks a lot man. This library has got awful documentation.

appcilious avatar Jun 28 '21 14:06 appcilious

I agree but at least he put in the work to make it possible, we should contribute! great add by the way!

PJTH3G0D avatar May 13 '22 23:05 PJTH3G0D