Jump to content
UBot Underground

Recommended Posts

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! :wub:

Link to post
Share on other sites

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.

  • Like 1
Link to post
Share on other sites

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 !

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...