Jump to content
UBot Underground

Regex to scrape phone numbers from page


Recommended Posts

    set(#phone, $find regular expression(#contactscrape, "(\\s*\\(?0\\d4\\)?\\s*\\d6\\s*)|(\\s*\\(?0\\d3\\)?\\s*\\d3\\s*\\d4\\s*)"), "Global")

So this is my code in ubot, but it is not working, my phone variable is blank and on www.rubular.com when i test this regex:

(\s*\(?0\d4\)?\s*\d6\s*)|(\s*\(?0\d3\)?\s*\d3\s*\d4\s*)

I match UK Numbers from this page:

http://www.hollywoodcinemas.net/norwich-contact

please help. why www.rubular.com match the numbers and inside bot i dont get result.

 

Link to post
Share on other sites

It doesn't work because your regex is totally broken (it must have changed while you were adding it to UBot).

 

Found a random regex for UK phone numbers and it works:

set(#phone, $find regular expression($scrape attribute(<tagname="html">, "innertext"), "(??:\\(?(?:0(?:0|11)\\)?[\\s-]?\\(?|\\+)44\\)?[\\s-]?(?:\\(?0\\)?[\\s-]?)?)|(?:\\(?0))(??:\\d\{5\}\\)?[\\s-]?\\d\{4,5\})|(?:\\d\{4\}\\)?[\\s-]?(?:\\d\{5\}|\\d\{3\}[\\s-]?\\d\{3\}))|(?:\\d\{3\}\\)?[\\s-]?\\d\{3\}[\\s-]?\\d\{3,4\})|(?:\\d\{2\}\\)?[\\s-]?\\d\{4\}[\\s-]?\\d\{4\}))(?:[\\s-]?(?:x|ext\\.?|\\#)\\d\{3,4\})?"), "Global")

  • Like 1
Link to post
Share on other sites
  • 2 weeks later...

Can i merge US and UK phone numbers if i use | or is there some other character that i can sue as or. So for example

Uk regex code|US regex code

 

Will this make it to check first for UK phone numbers and then after that for US phone numbers or i missunderstand something?

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...