Jump to content

Get info from another website.


jmac2501

Recommended Posts

Hey-

 

I run a real estate website and i show house listings on our website. I am looking for a way to gather info from our sorce website and save them to my database. here is an example of the website i need to get info from.

 

http://www.metrolistmls.com/cgi-bin/GetOneR.cfm?MLSNum=60131588

 

from this page i need the top most picture, address, beds, bath, Square feet, and agent values.

 

Is there a way to gather all this info and insert in into my database?

any help would be great.

Link to comment
https://forums.phpfreaks.com/topic/48542-get-info-from-another-website/
Share on other sites

You will need to create the rules for what data to pull.

 

where and how do i do that. I looked but couldn't find it. I did get it to pull up the website though.

 

You will need to inspect the layout of the page to find consistent rules for each piece of data. Hopefully, the pages are consistent - if not you will have real problems.

 

For example, let's say you want to get the number of bedrooms. A view of the page you posted shows that the bedrooms in the code is writen like this:

<td width="16%" class="FormTitle">Bedrooms</td>
<td width="14%" bgcolor="#f0f0f0">2</td>

 

So, in the text of the body that is returned you could do a search for

]<td width="16%" class="FormTitle">Bedrooms</td>

and then grab the value in the cell directly following that text. You would neet to create similar logic for all the other pieces of data you need.

 

The class also has some built in functions for dealing with table data. I have not used it myself, so I can't give any specific advice. I would try using those methods first.

The pages are consistent. I have been trying to use diffrent string functions to search and pull these values with no luck. can any one help me out with the code i should use for this and an example would be great. i need it to do this:

For example, let's say you want to get the number of bedrooms. A view of the page you posted shows that the bedrooms in the code is writen like this:

<td width="16%" class="FormTitle">Bedrooms</td>
<td width="14%" bgcolor="#f0f0f0">2</td>

 

So, in the text of the body that is returned you could do a search for

]<td width="16%" class="FormTitle">Bedrooms</td>

and then grab the value in the cell directly following that text. You would neet to create similar logic for all the other pieces of data you need.

 

The class also has some built in functions for dealing with table data. I have not used it myself, so I can't give any specific advice. I would try using those methods first.

 

this is what i got so far:

<?php
error_reporting(E_ALL ^ E_NOTICE);

require_once(dirname(__FILE__).'/class_http.php');

$h = new http();

$h->dir = "/home/foo/bar/"; 

if (!$h->fetch("http://www.metrolistmls.com/cgi-bin/GetOneR.cfm?MLSNum=70003411")) {

  echo "<h2>There is a problem with the http request!</h2>";
  echo $h->log;
  exit();
}

$msft_stats = http::table_into_array($h->body, "$", 1, not_null); 

/* Print out the array so you can see the stats data. */ 
echo "<pre>"; 
print_r($msft_stats); 
echo "</pre>"; 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.