仅查找结果之后的链接 [英] Find only links that are followed by outcomes

查看:79
本文介绍了仅查找结果之后的链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

引用此页面,我正在尝试获取所有链接,但只有那些后跟赔率的链接.您可能需要滚动几页才能看到该网站上的示例,或者在下面发布了屏幕截图.

Referencing this page, I'm trying to get all of the n Markets > links but ONLY those that are followed by odds. You may have to scroll through a few pages to see an example on the site or there is a screenshot posted below.

从屏幕截图中,我要的链接(绿色圆圈)后跟赔率(红色圆圈).我不希望链接(带有红色X标记)后面没有赔率(以黄色圈出).

From the screenshot, the links that I want (circled in green) are followed by odds (circled in red). I do NOT want the links (marked with a red X) that are not followed by odds (circled in yellow).

是否可以根据旁边是否存在.bettype:nth-child(1) .bet-party来获取所有.purple-arrow元素?

Is it possible to get all the .purple-arrow elements based on if .bettype:nth-child(1) .bet-party exists beside it?

应该很简单,只需跟在后面,就可以了,但这并不能满足要求.

Should be simple enough with following and preceding yet this is not giving desired.

//*[contains(@href,'/sports-betting/soccer/')]/ancestor::*[contains(@class,'bet-party')]/preceding-sibling::span['other-matches']//*[contains(@href, '/sports-betting/soccer/')]

推荐答案

您可以使用XPath进行此操作.

You can do this with XPath.

//div[@class='container-fluid'][not(.//div[contains(@class,'no-outcomes')])]//a[@class='purple-arrow']

打破现状

//div[@class='container-fluid']

找到一个包含类容器流体"的DIV.这些是顶级容器,可容纳每个匹配项的整行HTML.

Find a DIV that contains the class 'container-fluid'. These are the top level containers that hold the entire row of HTML for each match.

[not(.//div[contains(@class,'no-outcomes')])]

它不能具有包含无结果"类的后代DIV.如果DIV具有此类,则该行中没有赔率,因此我们不希望这些赔率.

It must not have a descendant DIV that contains the class 'no-outcomes'. If the DIV has this class, that row has no odds posted so we don't want these.

//a[@class='purple-arrow']

最后...返回带有紫色箭头"类的链接.

and finally... return the link with the class 'purple-arrow'.

您可以使用$x()在Chrome开发工具中对此进行测试.

You can test this in Chrome dev tools using $x().

这篇关于仅查找结果之后的链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆