Jordan Scrapes Secretary of State: Arkansas
Tags: webscraping, axios, cheerio, javascript
Published: 2020-10-22 21:36:59

---
title: Jordan Scrapes Secretary of State: Arkansas
published: true
date: 2020-09-21 12:50:00 UTC
tags: WebScraping,Axios,cheerio,Javascript
canonical_url: https://javascriptwebscrapingguy.com/jordan-scrapes-secretary-of-state-arkansas/?utm_source=rss&utm_medium=rss&utm_campaign=jordan-scrapes-secretary-of-state-arkansas
---

[Demo code here](https://github.com/aarmora/jordan-scrapes-secretary-of-states/tree/master/src/arkansas)

It is time for episode 19 in the [Secretary of State scraping series](https://javascriptwebscrapingguy.com/secretary-of-states/). Today we do some web scraping of the Arkansas Secretary of State, found [here](https://www.sos.arkansas.gov/corps/search_all.php?fullsite). I really don’t know much about Arkansas but that featured image certainly does look gorgeous.

## Investigation

![Arkansas gif](https://media.giphy.com/media/OPLZ6VNxfwY77BiOII/giphy.gif)

I try to look for the most recently registered businesses. They are the businesses that very likely are trying to get setup with new services and products and probably don’t have existing relationships. I think typically these are going to be the more valuable leads.

If the state doesn’t offer a date range with which to search, I’ve discovered a trick that works pretty okay. I just search for “2020”. 2020 is kind of a catchy number and because we are currently in that year people tend to start businesses that have that name in it.

Once I find one of these that is registered recently, I look for a business id somewhere. It’s typically a query parameter in the url or form data in the POST request. Either way, if I can increment that id by one number and still get a company that is recently registered, I know I can find recently registered business simply by increasing the id with which I search.

This is exactly the tactic used in Arkansas:

[![Searching for 2020 in Arkansas secretary of state.](https://javascriptwebscrapingguy.com/wp-content/uploads/2020/09/image-5.png)](https://javascriptwebscrapingguy.com/wp-content/uploads/2020/09/image-5.png)

Searching for 2020 reveals a list of businesses with 2020 in the name. Going through a few finds one that is registered recently, only a few months ago.

[![Finding a recent business with 2020 in the name](https://javascriptwebscrapingguy.com/wp-content/uploads/2020/09/image-6-1024x621.png)](https://javascriptwebscrapingguy.com/wp-content/uploads/2020/09/image-6.png)

Now let’s look at the details page for this business.

[![Details page for Arkansas business](https://javascriptwebscrapingguy.com/wp-content/uploads/2020/09/image-7.png)](https://javascriptwebscrapingguy.com/wp-content/uploads/2020/09/image-7.png)

Bam. We’re in business. You can see an id in the url. Incrementing that showed that businesses become more recent as the number got bigger.

Finding businsesses with the time tested method worked like a charm.

## The code

![](https://media.giphy.com/media/3NhHRPmCP9RMAjtdDf/giphy.gif)<figcaption>Looking at these pictures makes me want to visit Arkansas</figcaption>

The code is simple. We just loop through ids and then parse the html.

```
(async () => {
    const startingId = 566000;
    for (let i = 0; i <= 20; i += 1) {
        await getDetails(startingId + i);
        //Longer timeout needed because of DDOS protection from website
        await timeout(3000);
    }
})();
```

We added a longer wait time here to ensure that we aren’t risking getting blocked. Three seconds may be longer than you need and you can adjust that to whatever you need.

In this example we just loop through 20 times but if you get the newly registered businesses daily you want to stop once it stops finding new businesses.

The details code is also very simple.

```
async function getDetails(sosId: number) {
    const axiosResponse = await axios.get(`https://www.sos.arkansas.gov/corps/search_corps.php?DETAIL=${sosId}`);
    const $ = cheerio.load(axiosResponse.data);
    const title = $("tr:nth-of-type(2) td:nth-of-type(2)").text();
    const formationDate = $("tr:nth-of-type(11) td:nth-of-type(2)").text();
    const status = $("tr:nth-of-type(7) td:nth-of-type(2)").text();
    const agentName = $("tr:nth-of-type(9) td:nth-of-type(2)").text();
    const address = $("tr:nth-of-type(8) td:nth-of-type(2)").text();

    const business: any = {};
    business.title = title;
    business.formationDate = formationDate;
    business.sosId = sosId;
    business.status = status;
    business.agentName = agentName;
    business.address = address;

    console.log("business", business);
}
```

Arkansas was a very cut and dry scrape, which was nice. The end!

[Demo code here](https://github.com/aarmora/jordan-scrapes-secretary-of-states/tree/master/src/arkansas)

## Looking for business leads?

Using the techniques talked about here at [javascriptwebscrapingguy.com](https://javascriptwebscrapingguy.com), we’ve been able to launch a way to access awesome web data. Learn more at [Cobalt Intelligence](https://cobaltintelligence.com)!

The post [Jordan Scrapes Secretary of State: Arkansas](https://javascriptwebscrapingguy.com/jordan-scrapes-secretary-of-state-arkansas/) appeared first on [JavaScript Web Scraping Guy](https://javascriptwebscrapingguy.com).