I use many pages that break scratches with a simple delete button or even a slight glitch on the page.
This problem appears a lot, but I'm not sure how to get around it. In fact, since the team, the odds and everything that has disappeared, it gets an xpath with the link: ( //*[contains(@class, "sport-block") and .//div/div]//*[contains(@class, "purple-ar")]) . As expected, but not the team and the odds creating a worthless scratch.
I originally used the CSS selector, but I can't imagine how this would be possible with CSS limitations.
Simple xpath I am after:
//*[contains(@class, "sport-block") and .//div/div]//*[contains(@class, "purple-ar")]
The problem remains.
I am not very familiar with the ancestors and precedes ... But something like xpath:
ie: //a/ancestor::div[contains(@class, 'xpath')]/preceding-sibling::div[contains(@class, 'xpath')]//a
in
//a/ancestor::div[contains(@class, 'table-grid')]/preceding-sibling::span[contains(@class, 'sprite-icon arrow-icon arrow-right arrow-purple')]//a
May solve (assuming I can make this work).
<td class="top-subheader uppercase"> <span> English Premier League Futures </span> </td> </tr> <tr> <td class="content"> <div class="titles"> <span class="match-name"> <a href="/sports-betting/soccer/united-kingdom/english-premier-league-futures/outright-markets-20171226-616961-22079860"> Outright Markets </a> </span> <span class="tv"> 26/12 </span> <span class="other-matches"> <a href="/sports-betting/soccer/united-kingdom/english-premier-league-futures/outright-markets-20171226-616961-22079860" class="purple-arrow">5 Markets <span class="sprite-icon arrow-icon arrow-right arrow-purple"></span> </a> </span>
Any ideas how I can get around this problem? Thanks.
Current output:
Steaua Bucharest Link for below Celtic Link for below Napoli Link for below Lyon Link for below
Desired:
Steaua Bucharest LINK FOR Steaua Bucharest Celtic Link Celtic Napoli Link for Napoli Lyon Link for Lyon

Any ideas how I can get around this? Or even a narrowed approach? Constant problem. Thanks.
python css xpath selenium web-scraping
user9045698
source share