Connecting Tech Pros Worldwide Forums | Help | Site Map

Extracting Data

Member
 
Join Date: Jan 2008
Posts: 121
#1: Mar 4 '08
Hi,

How would i go about doing the following.

I have a URL like this e.g. www.website.co.uk/orgs-details.asp?OrgsID=

On this page there is Company Name, Contact:, Tel, E-mail: and Web site:

I want to extract these details and add them into a table.

How would i do this?

This is how the data is shown if this helps?
Expand|Select|Wrap|Line Numbers
  1. <table width="385" border="0" cellspacing="0" cellpadding="0"> 
  2.               <tr> 
  3.                 <td valign="top"><h1>Company Name</h1> 
  4.                   <table width="100%" border="0" cellspacing="0" cellpadding="3"> 
  5.                     <tr> 
  6.                       <th width="30%"><strong>Contact:</strong></th> 
  7.                       <td width="70%"><strong>Persons Name 
  8.                         </strong> </td> 
  9.                     </tr> 
  10.  
  11.                     <tr> 
  12.                       <th><strong>Tel:</strong></th> 
  13.                       <td><strong>000 000 000</strong></td> 
  14.                     </tr> 
  15.                     <tr> 
  16.                       <td>&nbsp;</td> 
  17.                       <td><span class="small">Information Here</span>.</td>
  18.  
  19.                     </tr>
  20.  
  21.                     <tr> 
  22.                       <th><strong>E-mail:</strong></th> 
  23.                       <td><strong><a href="info@website.com">info@website.com</a></strong></td> 
  24.                     </tr> 
  25.  
  26.                     <tr> 
  27.                       <th><strong>Web site:</strong></th> 
  28.                       <td><strong><a href="http://www.website.com" target="_blank" id="451" onClick="return trackclick(this.id);" title="Visit Site">www.website.com</a></strong></td> 
  29.                     </tr> 
  30.  
  31.                   </table>

Cheers,
Adam

ronverdonk's Avatar
Moderator
 
Join Date: Jul 2006
Location: The Netherlands
Posts: 4,139
#2: Mar 4 '08

re: Extracting Data


I do not understand exactly what you want to accomplish.

Is that url you show yours? Or do you want to 'scrape' a website: extract the data from a remote website and store it into your own page?

And what are the 'tables'you talk about, your HTML table or a database table?

Ronald
TheServant's Avatar
Expert
 
Join Date: Feb 2008
Location: Australia
Posts: 914
#3: Mar 4 '08

re: Extracting Data


Who puts the data on there? If it is the companies themselves they must use a form, and you could just incorporate some database storage code with the form.

Also, is that data currently being called by the page (using sessions, MySQL or something else), or is it just written in the html? If it is being called then you already have the information stored.

If you just want to know how put a name in a table, you need to use php in something like:
[HTML]<tr>
<th width="30%"><strong>Contact:</strong></th>
<td width="70%"><strong><?php echo($persons_name); ?></strong> </td>
</tr>[/HTML]

If this makes no sense, you need to learn php, inparticular: variables.
Member
 
Join Date: Jan 2008
Posts: 121
#4: Mar 4 '08

re: Extracting Data


I want to extract data from one of my old sites and put it into a an sql database.

So basically i need something that will loop through all the page e.g. id=1, id=2 etc and will put the data from each id into an sql database table.
Member
 
Join Date: Jan 2008
Posts: 121
#5: Mar 5 '08

re: Extracting Data


Could something like this be adapted to work that i have used in the past to extract email addresses:

[PHP]
for($i=1;$i<$max_val;$i++) {
$content = file_get_contents('http://www.website.com/slist.php?item='.$i);
preg_match_all($email_match_regex, $content, $matches);
if(count($matches[0])) {
foreach($matches[1] as $index => $value) {
$insert_id = mysql_query('INSERT INTO.....');
}
}
}
[/PHP]
Reply