aggin23 1 Posted July 7, 2017 Report Share Posted July 7, 2017 Hi, I'm trying to scrape only numbers, unfortunately the number is in the same class with the rest of text. <span class="stats-row">15 Items Avaible</span>I need this value for comparison. Also, i want to remove brackets from scraped innertext :<a href="#reviews" class="gig-ratings-count js-gtm-event-auto" data-gtm-category="gig-page-triple" data-gtm-action="click" data-gtm-label="buyer-reviews">(205)</a> Thank for help in advance! Quote Link to post Share on other sites
BoosterBots 23 Posted July 7, 2017 Report Share Posted July 7, 2017 You can use regular expressions for this. Set a var to find regular expression from the doctext you are searching. Here is a way to pull out just the number from this text:<span class="stats-row">15 Items Avaible</span> Regular Expression:(?<=class="stats-row">)\d+(?=\s) To grab the number from this text:<a href="#reviews" class="gig-ratings-count js-gtm-event-auto" data-gtm-category="gig-page-triple" data-gtm-action="click" data-gtm-label="buyer-reviews">(205)</a> Regular Expression:(?<=buyer-reviews">\()\d+(?=\)<) Also, remember to check the source code and see how many matching items you get. That way you know you are pulling the correct data. 1 Quote Link to post Share on other sites
aggin23 1 Posted July 7, 2017 Author Report Share Posted July 7, 2017 You can use regular expressions for this. Set a var to find regular expression from the doctext you are searching. Here is a way to pull out just the number from this text:<span class="stats-row">15 Items Avaible</span> Regular Expression:(?<=class="stats-row">)\d+(?=\s) To grab the number from this text:<a href="#reviews" class="gig-ratings-count js-gtm-event-auto" data-gtm-category="gig-page-triple" data-gtm-action="click" data-gtm-label="buyer-reviews">(205)</a> Regular Expression:(?<=buyer-reviews">\()\d+(?=\)<) Also, remember to check the source code and see how many matching items you get. That way you know you are pulling the correct data.Amazing, regex for me is like black magic. Thank you ! Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.