Jump to content

Recommended Posts

Hey all,

I'm brand new to PHP/SQL, and haven't really gotten into AJAX/JavaScript yet.

 

I have my own server, running PHP and MySQL, and one of the pages brings up information about area hospitals. (Capacity, services, helicopter pad (BOOL), helo pad lat/long, contact information, etc). I have a summary page that shows the most important information, and I would like to receive updates from another site: (hospitalstatus.emsi.org)

 

This website is operated by the region and shows the status (Open, Delay, Closed, etc) for each hospital.

 

Is there a way to collect this data on my own, without having direct access to their server? Some way to scan the HTML and gather data?

 

From "View Source", this is the code. The ID numbers are static, so I could reference them in my code

<TD CLASS="alt" NOWRAP>
<A HREF="hosp_log.cfm?id=15">AGH - Suburban Campus</A></TD>
<TD>  	<FONT COLOR="GREEN">OPEN  </TD>
<TD NOWRAP>04/04/07 08:55  </TD>

 

Thanks!

Link to comment
https://forums.phpfreaks.com/topic/200507-i-think-this-is-an-ajax-function/
Share on other sites

That was a paraphrased quote from the O'Rielly PHP book that I got...lol

 

Someone on another board helped me with this regex, but the problem is I get an "unexpected modifier: ")"" error. I've tried escaping all \\ and have done things like:

$regex = "<a....z]*)"; 
preg_match_all('$regex',$url,$result); // with and without single quotes
--Causes "Unexpected T_STRING" error..

 

New Regex: 
preg_match_all('<a\b((?!\bid\s*=|>).)*id\s*=(\d+)[^>([^<]*).*?<font\b[^>]*>([a-z]*)',$url,$result);

Any ideas??

 

I had a much simpler regex at one point, but

"echo $result[x];" (where X stands for anything I try to put in there)

would simply yield "Array" or "Array()", i forget which. I think this is a basic me-not-knowing-PHP issue, but any insight on how I messed up the array would be great too :)

 

Thanks again!

 

 

<?php
$url = file_get_contents('http://hospitalstatus.emsi.org');
preg_match_all('#<a\b((?!\bid\s*=|>).)*id\s*=(\d+)[^>([^<]*).*?<font\b[^>]*>([a-z]*)#',$url,$result);
echo $result[1];
?>

Returns the following error: Compliation failed: unmatched parentheses at offset 42 on line 3.

 

If its talking about the 42nd character, that's after the second "id" and before the "\s".

 

I don't see any unmatched parentheses?

offest 42 means within the pattern, not on that line of code. I'm not entirely sure what your pattern does but the issue I believe is this segment here...

 

(\d+)[^>([^<]*)

 

I think that the first [ is creating a character class meaning that ^>([^ is being considered the contents of the character class. Because the opening bracket is inside the class, the closing bracket doesn't have a 'partner'. Without knowing more it's hard to say if there is a ] missing and it should be [^>]([^<]*), though that seems unlikely, or possibly the [^< is erroneous and it should be (\d+)([^<]*).

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.