alexb 2 Posted May 20, 2015 Report Share Posted May 20, 2015 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, Quote Link to post Share on other sites
HelloInsomnia 1103 Posted May 20, 2015 Report Share Posted May 20, 2015 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") Quote Link to post Share on other sites
UBotBuddy 331 Posted May 21, 2015 Report Share Posted May 21, 2015 @alexbHelloInsomnia beat me to the punch so kudos to him! I provided an example that you can download and study. Zillow-lesson.ubotInside 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 1 Quote Link to post Share on other sites
alexb 2 Posted May 21, 2015 Author Report Share Posted May 21, 2015 HelloInsomnia and UbotBuddy, Thank you both! Very helpful and I now have it working, but still need to learn regex! Quote Link to post Share on other sites
HelloInsomnia 1103 Posted May 21, 2015 Report Share Posted May 21, 2015 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. Quote Link to post Share on other sites
UBotBuddy 331 Posted May 27, 2015 Report Share Posted May 27, 2015 Congrats to you. Commitment and Practice and you will learn anything! I'm sure Helloinsomnia's course will get you far deeper into Regex thanyou can go from a book that I learned from. Buddy 1 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.