Jump to content
UBot Underground

Scraping Phone Numbers Only From Within Scrape Attribute


Recommended Posts

Hi, Here is the example page I am scraping:
http://www.zillow.com/homedetails/2329-Onyx-Rd-North-Pole-AK-99705/2106119627_zpid/

My code that I am trying to scrape phone number only (I want to append a file without adding the Call in the scrape attritubute):

add item to list(%phones,$find regular expression($scrape attribute($element offset(<class="snl phone">,1),"innertext"),"^(\\+\\d\{1,2\}\\s)?\\(?\\d\{3\}\\)?[\\s.-]\\d\{3\}[\\s.-]\\d\{4\}$"),"Delete","Global")

In the debugger, I am getting on 0, without any phone number data.

Any ideas on how to accomplish this?  (I can scrape the attribute no problem, but it adds Call xxx-xxx-xxxx and I just want phone only)

Thank you,

Link to post
Share on other sites

Try this:

add item to list(%phones, $find regular expression($scrape attribute($element offset(<class="snl phone">, 1), "innertext"), "(\\+\\d\{1,2\}\\s)?\\(?\\d\{3,3\}\\)?[\\s.-]\\d\{3,3\}[\\s.-]\\d\{4,4\}$"), "Delete", "Global")
Link to post
Share on other sites

@alexb

HelloInsomnia beat me to the punch so kudos to him!  ;)

I provided an example that you can download and study.   Zillow-lesson.ubot

Inside of the bot are 4 tabs.  One is an On Load that navigates to the web page that you shared.

The next 3 tabs are variations of what you are attempting to scrape.

The first tab shows a step by step approach.

The second tab shows a stacked method whereby I took the first tabs items and squeezed them into less commands.

In the third tab I went further using what HelloInsomnia was showing you and squeezed my code into just two commands.

Hopefully, both of our examples can help you or others looking to learn this technique.

Good Luck!

UBotBuddy

  • Like 1
Link to post
Share on other sites

HelloInsomnia and UbotBuddy,

 

Thank you both!  Very helpful and I now have it working, but still need to learn regex!

 

 

No problem, glad you got it working. I have a regex course if you're interested I can send you the details.

Link to post
Share on other sites

Congrats to you.

 

Commitment and Practice and you will learn anything!

 

I'm sure Helloinsomnia's course will get you far deeper into Regex than

you can go from a book that I learned from.

 

Buddy

  • Like 1
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...