equal-aqua
equal-aqua3y ago

click on a specific word of a span

Hi everyone, I'm new to the word of scraping and crawling. For the time being I'm using Playwright, and I just learned of crawlee. I'm stuck in playwright, and perhaps crawlee will help. I need to click at the starting and ending words of a span element. Is there anyway select a specific word of a span? Alternatively, is there any way to CREATE a DOM element with playwright? Perhaps I could create a DIV around these two words, then click on those DIV. Or even alternatively, I can get the coordinates of a given word, and click away. Is any of this possible? Thanks
3 Replies
Alexey Udovydchenko
Imho try to create div's (or better child span's): plain text in span is single data entity so calculating coordinates to click is not safe and complex approach
equal-aqua
equal-aquaOP3y ago
Been looking around and I think the only way to create new elements such as divs or child spans would be with an evaluate function and good old javascript or an arrow function. Is that the case? I'm fairly inexperienced with scraping, playwright and javascript in general.
Alexey Udovydchenko
see https://github.com/microsoft/playwright-dotnet/issues/1796 and also on second though <a> might work better, since clicks will not be lost if higher parent is also clickable

Did you find this page helpful?