Jump to content

noob Help with php


dxh

Recommended Posts

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

 

Link to comment
Share on other sites

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);
         }
      }

Link to comment
Share on other sites

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.