Shopify Store Speed Optimization: Remote Developer’s Strategies

Having a speedy and efficient store can set you apart from the competition. Especially in a world where online shopping is more popular than ever. If you’re a remote developer for a Shopify store, ensuring its performance is top-notch should be a priority. Here, we’ll explore six strategies that supercharge your Shopify store. 

(more…)

Ensuring Data Security: The Crucial Role of Web Development in Achieving SOC 2 Compliance

Ensuring Data Security: The Crucial Role of Web Development in Achieving SOC 2 Compliance

With data breaches and cyber-attacks becoming more prevalent, organizations must take proactive steps to secure their data—not only can this protect the organization from potential legal and financial liabilities, but it can also help build trust with customers. One of the best ways to demonstrate commitment to data security is to achieve SOC 2 compliance.

(more…)

Scrape yellow pages using PHP

Yellow Pages is a business directory website that contains listings for businesses, organizations, and individuals. It was originally created as a printed directory in the late 19th century, with business listings arranged by category and alphabetically within each category. The name “Yellow Pages” comes from the color of the paper used for the directory.

We can use the data available on the website to build a cold call list in order to sell our products to target customers. We are going to scrape the name of the restaurant and its contact number from this page. And then save the data to a CSV file for easy access.

Setting up the prerequisites

I am assuming that you have already installed php on your machine. Apart from this, we will use built-in libraries.

  1. DOMDocument: DOMDocument is a built-in PHP library that provides an object-oriented interface for working with XML and HTML documents. It allows you to parse, manipulate, and generate XML and HTML documents.
  2. curl: For making the HTTP connection with the website.

Downloading raw data from yellowpages.com

Using the curl library we are going to download raw HTML data from the target website.

// Initialize a new cURL session
$curl = curl_init();

// Set the URL to fetch
$url = "https://www.yellowpages.com/los-angeles-ca/restaurants";
curl_setopt($curl, CURLOPT_URL, $url);

// Set the option to return the response as a string
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

// Execute the cURL request and fetch the response
$response = curl_exec($curl);

// Close the cURL session
curl_close($curl);

Once you run this code you will get the HTML content of the target website.

Before we use DOMDocument to parse the data, let’s find the location of each element.

Each box is located inside a div tag with the class result. You can check it in the image below.

Let’s find the location of the name tag.

Here we can see that the name is stored in a tag.

Now, let’s see where the number is stored.

You can find the number inside the div tag with class phones.

Now, we have the location of the data element we want to extract.

// Initialize a new cURL session
$curl = curl_init();

// Set the URL to fetch
$url = "https://www.yellowpages.com/los-angeles-ca/restaurants";
curl_setopt($curl, CURLOPT_URL, $url);

// Set the option to return the response as a string
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

// Execute the cURL request and fetch the response
$response = curl_exec($curl);

// Close the cURL session
curl_close($curl);

// Create a new DOMDocument object and load the HTML data
$dom = new DOMDocument();
$dom->loadHTML($response);

// Find all the restaurant listings on the page
$listings = $dom->getElementsByTagName('div');
foreach ($listings as $listing) {
  if ($listing->getAttribute('class') == 'result') {
      // Extract the name and phone number of the restaurant
      $name = trim($listing->getElementsByTagName('a')[0]->nodeValue);
  $phone = trim($listing->getElementsByTagName('div')[0]->getElementsByTagName('p')[0]->nodeValue);

   }

}

Here we created a constructor for DOMDocument and then we are loading the raw data in it.

Let’s now create a CSV file to save the data.

// Initialize a new cURL session
$curl = curl_init();

// Set the URL to fetch
$url = "https://www.yellowpages.com/los-angeles-ca/restaurants";
curl_setopt($curl, CURLOPT_URL, $url);

// Set the option to return the response as a string
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

// Execute the cURL request and fetch the response
$response = curl_exec($curl);

// Close the cURL session
curl_close($curl);

// Create a new DOMDocument object and load the HTML data
$dom = new DOMDocument();
$dom->loadHTML($response);

// Create a new CSV file and write the header row
$fp = fopen('restaurants.csv', 'w');
fputcsv($fp, array('Name', 'Phone Number'));

// Find all the restaurant listings on the page
$listings = $dom->getElementsByTagName('div');
foreach ($listings as $listing) {
  if ($listing->getAttribute('class') == 'result') {
      // Extract the name and phone number of the restaurant
      $name = trim($listing->getElementsByTagName('a')[0]->nodeValue);
      $phone = trim($listing->getElementsByTagName('div')[0]->getElementsByTagName('p')[0]->nodeValue);

       // Write the data to the CSV file
      fputcsv($fp, array($name, $phone));

   }

}

// Close the CSV file
fclose($fp);

Summary of the complete code:

In this code, we first fetch the HTML data using cURL. We then create a new DOMDocument object and load the HTML data into it using the loadHTML() method.

Next, we create a new CSV file using the fopen() function and write the header row to it using the fputcsv() function.

We then find all the restaurant listings on the page using the getElementsByTagName() method and loop through them. For each listing, we extract the name and phone number of the restaurant using the nodeValue property and the trim() function to remove any extra whitespace.

Finally, we write the data to the CSV file using the fputcsv() function and close the file using the fclose() function.

Once you run the code you will find the name of the restaurant and their phone numbers in a CSV file. The file will be in the same folder as your main php scraper file.

Read More: Scraping Yellow Pages with Python

Conclusion

In conclusion, scraping Yellow Pages using PHP can be an effective way to access a large database of business information, gain insights into market trends and customer preferences, and generate leads for your business. By automating the data collection process, you can save time and resources while collecting valuable data.

With proper planning and execution, scraping Yellow Pages can be a powerful tool for businesses looking to gain a competitive edge and make informed business decisions.


Guest Author Information

Author Name:– Manthan Koolwal

Author Bio – Manthan loves to create web scrapers. He has been working on them for the last 10 years now. He has been creating data pipelines for multiple MNCs in past Currently, he is working on Scrapingdog. It is a web scraping API that can scrape any website without blockage at any scale. Feel free to connect him for any web scraping query. 

Author website – https://www.scrapingdog.com


5 PHP web scraping libraries that you should use

Web Scraping is evolving every day. There are new methods and new libraries every day for making web scraping fun and easy. First, let’s understand why we do web scraping, and then we will focus on the top 5 PHP libraries that can help you scrape websites quickly.

(more…)

Top 8 mistakes website owners make with their WordPress websites

Building a new website can be a lot of hustle. Still, one thing most website owners don’t think about is that maintaining and handling a WordPress website can also contain specific challenges, which often lead to several mistakes.

Regardless of your excellent skills working through your site, the expertise and analysis of a professional developer go unmatched. The top thing you should do is upgrade your skills and avoid making silly errors.

For those who are concerned with making mistakes, here is a research list of the most common mistakes that WordPress website owners make.

  1. Not backing up your site

This guess is quite common, yet most website owners don’t get the reason behind regular backup of their sites. Nothing is error-free, not even such a long-standing technology as WordPress. Your websites might never collide, but the sites will perform well in the future if you do backups.

Generating a WordPress backup is as easy as ABC. You can either use a plugin like WP-DB-Backup or just backup your website by going to Tools > Clicking Export.

  1. Installing extra plugins 

You may end up installing every plugin because of FOMO. Plugins affect your website’s speed, and many plugins are not even compatible with one another.

Think to yourself, “Is that plugin essential for performing my website”? If your thoughts go on the negative side, it might not be the most accurate plugin for your site. Delete the plugins you do not use. Many times, an installed plugin can conflict with other installed plugins. 

  1. Forgetting image optimization

Images are the key elements of your content marketing tactics. Visuals are processed 60,000 times faster than text by the average human brain. So, include formulas in your content and optimize them. Here are some primary image attributes that are optimized:

  • Alt Text: It is a brief description of what the visual includes. The sites need to have alt text to rank. Alt Text is the only thing your users will set to load or open.
  • Title: It is used on a separate page that opens up when the user taps on the image. Alter the name of the file while uploading it to WordPress.
  • Description: It displays some additional information about the visual on a separate page along with the title. If you allow the users to open a separate attached page, make sure you have all the details noted.
  • Image: The title attribute shows up when you hover over an image. Image title attributes can be anything from an image title to a description or a separate snippet of text.
  1. Not selecting a responsive theme

Mobile phones are ubiquitous. At present, we are accessing websites on the go, so you must give users easy access to information while they are standing somewhere or commuting to work. Most themes have responsive designs, but once in a while, you could get stuck with a non-responsive one.

Your WordPress website may no longer be responsive if it has been not active for a while. Considering the rapidly increasing rate at which mobile phones are overpowering the world, it might be the right time for an update.

  1. Neglecting the comments section

The main purpose of the comment section is to improve user engagement. Most companies know that they need to engage their users but never take the help of the comment section. Many times they even ignore the incoming questions and reviews.

If you want your users to believe that you care about them and that your firm is thriving, it’s important to include the comment section and maintain it by keeping the section clean, replying to the genuine ones, and removing all the spam ones.

  1. Creating unnecessary categories

Categories define a subtle content organization. However, some website owners create way too many categories. It gets complicated for the users to decide what your website is about, and the website turns out to be a confusing search tool for information.

The best way to organize your content is to have a limited number of top-level categories and use tags for low-level organizations.

  1. Avoiding SEO Strategies

Content marketing is a complex field, and day by day, every expert has somehow agreed on the fact that content writing is not just about writing blog posts. Content overload is real now. There is simply way too much content production going on everywhere, and organizations are competing on the quality of content as well as its discovered sources.

One of the most effective content marketing techniques that cannot be avoided is SEO. With the Yoast SEO Plugin, you can even raise your SEO rankings. Yoast provides you with all the recommendations and suggestions and a simple way to follow them.

  1. Blocking websites from SERP

While you are still working on its functionalities, WordPress has the unique feature of discouraging SERPs from finding your website. But sometimes, website owners tend to forget to uncheck the box, and this prevents Google from discovering your website even when it is ready to go around.

This error can be easily fixed by going to Settings>Reading and making sure the “Discourage search engines from indexing the site” box is unchecked. 

Final say

Mistakes happen often while developing a website, but you can easily manage to build a mistake-free WordPress website by hiring developers. India is a hub of software developers where you can get experienced and skilled developers at lower costs and one can easily hire dedicated developers in India and get the task done easily in a cost-effective way without compromising on the quality.

So, give your website the attention it deserves and watch it thrive!

Guest Author

Harikrishna Kundariya, a marketer, developer, IoT, ChatBot & Blockchain savvy, designer, co-founder, Director of eSparkBiz Technologies @Software Development Company. His 10+ experience enables him to provide digital solutions to new start-ups based on IoT and ChatBot.


📰 Get your brand, product, or service the attention it deserves with affordable classified ad placement in the OpenLampTech newsletter. I appreciate your support!