Pulling in content from other site?

Scenario: Suppose I have a local news site, and a local real estate site; both Wordpress.

The real estate site pulls in listings from through an API which updates every few hours.

I would like to pull in, say 10 of the newest listings from the real estate site, and display them on the other site. I’d update that “list” something like a couple times per day (add something to the chron?)?

Basically I want to parse a specific page on another site to find a specific ul (that has the listings), then create another ul on the other site to display on the site. The data would be more or less the same.

I’m not expecting anybody to write the code for me, but supposed I want to do something like that, what would be the best way to go about it?

The real estate listings on the real estate site are displayed in a ul like below:

<li class="IDX-resultsCell" data-propcat="active" data-idxid="a001" data-idxstatus="active" data-price="260000" data-listingid="21145757" data-mlsptid="1"><article id="0,0" class="IDX-listing idx-listing" data-price="$260,000"><div class="idx-listing__courtesy"></div><div class="idx-listing__photo"><a href="https://idx-firstimpression.idxbroker.com/idx/details/listing/a001/21145757/672-BRYANT-ST-FALLS-CITY-Falls-City-OR-97344" title="View this property"><img class="IDX-resultsPhotoImg" src="https://s3.amazonaws.com/mlsphotos.idxbroker.com/photos/7372/2737d0df461b23ab5b1f7b81d53cacec/a001" data-src="https://s3.amazonaws.com/mlsphotos.idxbroker.com/photos/7372/2737d0df461b23ab5b1f7b81d53cacec/a001" alt="Listing 21145757"></a><a data-listingid="21145757" data-idxid="a001" href="#saveProperty" class="idx-listing__action idx-listing__action--save IDX-saveProperty" id="IDX-SP-a001-21145757"><span class="fa-stack"><i class="fa fa-heart fa-stack-1x"></i><i class="fa fa-heart-o fa-stack-1x"></i></span></a><div id="idx-mls-logo" class="idx-mls__logo"><img src="https://s3.amazonaws.com/staticos.idxbroker.com/mls-logos/a001-logoURL" width="100" height="50" border="0" alt="MLS Logo"></div></div><div class="idx-listing__status"><h5>Active</h5></div><div class="idx-listing__price">$260,000</div><div class="idx-listing__address idx-text--overflow"><span class="IDX-resultsAddressNumber">672&nbsp;</span><span class="IDX-resultsAddressName">BRYANT ST FALLS CITY</span><span class="IDX-resultsEndAddressCommaOne">, </span><span class="IDX-resultsAddressCity">Falls City</span><span class="IDX-resultsEndAddressCommaTwo">, </span><span class="IDX-resultsAddressState">Oregon </span><span class="IDX-resultsAddressStateAbrv">OR</span><span class="IDX-resultsAddressZip IDX-hidden">&nbsp;97344</span></div><div class="idx-listing__features"><hr><div class="idx-listing__feature"><i class="fa fa-bed"></i>
                                                                                                                        3 Bedrooms                        
                                </div><div class="idx-listing__feature"><i class="fa fa-bath"></i>
                                                                                                                        2 Total Baths                        
                                </div><div class="idx-listing__feature"><i class="fa fa-object-group"></i>
                                                                                                                        1,206 SqFt                        
                                </div><div class="idx-listing__feature"><span><svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 12.18 12.38" style="enable-background:new 0 0 12.18 12.38;" xml:space="preserve"><style type="text/css">
                                          .st0{fill:var(--idx-theme-secondary);}
                                      </style><g><path class="st0" d="M11.05,3.95v4.5h0.38c0.41,0,0.75,0.34,0.75,0.75v2.25c0,0.41-0.34,0.75-0.75,0.75H9.18
                                              c-0.41,0-0.75-0.34-0.75-0.75v-0.38h-4.5v0.38c0,0.41-0.34,0.75-0.75,0.75H0.93c-0.41,0-0.75-0.34-0.75-0.75V9.2
                                              c0-0.41,0.34-0.75,0.75-0.75H1.3v-4.5H0.93c-0.41,0-0.75-0.34-0.75-0.75V0.95c0-0.41,0.34-0.75,0.75-0.75h2.25
                                              c0.41,0,0.75,0.34,0.75,0.75v0.37h4.5V0.95c0-0.41,0.34-0.75,0.75-0.75h2.25c0.41,0,0.75,0.34,0.75,0.75V3.2
                                              c0,0.41-0.34,0.75-0.75,0.75H11.05z M1.3,2.83h1.5v-1.5H1.3V2.83z M2.8,9.58H1.3v1.5h1.5V9.58z M9.93,3.95H9.18
                                              c-0.41,0-0.75-0.34-0.75-0.75V2.45h-4.5V3.2c0,0.41-0.34,0.75-0.75,0.75H2.43v4.5h0.75c0.41,0,0.75,0.34,0.75,0.75v0.75h4.5V9.2
                                              c0-0.41,0.34-0.75,0.75-0.75h0.75V3.95z M9.55,2.83h1.5v-1.5h-1.5V2.83z M11.05,9.58h-1.5v1.5h1.5V9.58z"></path></g></svg></span>
                                                                                                                        0.520 Acres                        
                            </div><hr></div></article></li>

Standard Disclaimer #4: Check and comply with the Terms of Service of the site you want to use the data from.

Sorry, I should have been more clear. I actually own both sites.

If you own both sites, why not create an API of some sort on the real estate site that produces the information in the format you need for the other site, rather than having code to extract it from a formatted page? That way you won’t need to rewrite it if/when you change the format on the page.

Or, for that matter, if you own both sites… why does the second site not access the same API the first site is, and pull down the data in exactly the same manner?

Don’t reinvent the wheel.

3 Likes