logo
languageENdown
menu

Build a Website Phone Number Extractor Step by Step

2 min read

Do you want to get sales leads in bulk? Then, you are on the right page. Web scraping is an efficient way to extract phone numbers from the web efficiently. With this article, you will be able to learn how to build a “Phone Number Extractor” with Octoparse.

Build Phone Extractor with Octoparse

Octoparse enables you to extract all the phone numbers from the web page with its advanced features. For example, if you are looking at all the lawyers in Dallas, Texas (United States) on www.lawyers.com, you will see the perfect results with all the detailed information of each lawyer.

But you may also notice that some phone numbers on the web page will appear after clicking on the “VIEW PHONE#” button and the location of the PHONE NUMBER button may change according to the contact information posted by different lawyers.

So, how do you extract all the phone numbers of lawyers in Dallas, Texas from this site? The solution is to modify the X Path generated by Octoparse to accurately extract the phone numbers information wherever it is.

Firstly, there are 17 pages for the results. 

You can get the following list of URLs as follows.

https://www.lawyers.com/all-legal-issues/dallas/texas/law-firms-p1/

https://www.lawyers.com/all-legal-issues/dallas/texas/law-firms-p2/

https://www.lawyers.com/all-legal-issues/dallas/texas/law-firms-p3/

https://www.lawyers.com/all-legal-issues/dallas/texas/law-firms-p2/

https://www.lawyers.com/all-legal-issues/dallas/texas/law-firms-p17/

Create a loop to extract data from the list of URLs.

Then extract all the phone numbers of the lawyers, and modify the X Path.

 

The result seems pretty good, right?

Before extracting any data from websites, I’d strongly recommend you read the terms of service of the website you want to pull data from and thus avoid legal issues. I’ve attached the Octoparse file (Click HERE) and you can download it to extract the data directly after you launch Octoparse. 

Octoparse is not just used to extract phone numbers, but also to extract other web content from complex websites using techniques such as AJAX, JavaScript, pagination, etc.. Try out more features now!

Web Scraping Legality

However, in some cases, scraping private data for business use may lead to legal issues. No worries, we have done a bit of an explanation for the website scraping legality here:

Is web scraping via Octoparse legal and ethical?

Is Web Crawling Legal? Well, It Depends.

Is Web Scraping Legal in some Countries?

Web Scraping 101: 10 Myths that Everyone Should Know

Hot posts

Explore topics

image
Get web automation tips right into your inbox
Subscribe to get Octoparse monthly newsletters about web scraping solutions, product updates, etc.

Get started with Octoparse today

Download

Related Articles