dxh Posted May 1, 2009 Share Posted May 1, 2009 I have this scraper that was written in php. It scrapes jpegs from webcams and puts them on my website. Problem is that a cam was replaced that writes jpegs under a different name. So my scraper does not scrape it. I need to put an "or" like statement in the code, but I can't code Here is what I have: if(checkTime()) { $qry = "SELECT * FROM CaboCams ORDER BY id ASC"; $res = mssql_query($qry); $timeout = 30; $old = ini_set('default_socket_timeout', $timeout); while($cam = mssql_fetch_assoc($res)) { sleep(2); $addr = 'http://' . $cam['ip'] . '/netcam.jpg'; $image = @file_get_contents($addr); if($image != -1) { writeImage($cam['id'], $image); } } (Not entire scraper, just the relevant part) I need to add code that will tell it to scrape an image named img.jpeg as well $addr = 'http://' . $cam['ip'] . '/img.jpg'; Can anyone give a dumb guy like me suggestions to figure this out. Thanks for your time. Cheers David Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 1, 2009 Share Posted May 1, 2009 if(checkTime()) { $qry = "SELECT * FROM CaboCams ORDER BY id ASC"; $res = mssql_query($qry); $timeout = 30; $old = ini_set('default_socket_timeout', $timeout); while($cam = mssql_fetch_assoc($res)) { sleep(2); $addr = 'http://' . $cam['ip'] . '/netcam.jpg'; $image = @file_get_contents($addr); if($image != -1) { writeImage($cam['id'], $image); } sleep(2); $addr = 'http://' . $cam['ip'] . '/img.jpg'; $image = @file_get_contents($addr); if($image != -1) { writeImage($cam['id'], $image); } } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.