Re: [PHP] Re: Can this be done?

2009-05-05 Thread Miller, Terion



On 5/5/09 8:31 AM, php news feed maarte...@scullix.co.za wrote:

post the script, and example of data

Miller, Terion tmil...@springfi.gannett.com wrote in message
news:c6259e7b.e91%kmille...@springfi.gannett.com...
Ok I have a script that grabs data from a page and puts it in a db, I need
to run this script 26 times on 26 different pages on the same site, is there
a way to do this without making 26 different scripts load? Should I post the
script?

Thanks,
T.Miller


__ Information from ESET Smart Security, version of virus signature
database 4053 (20090505) __

The message was checked by ESET Smart Security.

http://www.eset.com




__ Information from ESET Smart Security, version of virus signature 
database 4053 (20090505) __

The message was checked by ESET Smart Security.

http://www.eset.com




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Here is the script:
?php include(inc/dbconn_open.php); include(inc/dom.php); 
error_reporting(E_ALL); $TESTING = TRUE; $target_url = 
http://www.greenecountymo.org/sheriff/warrants.php;; $userAgent = 
'Googlebot/2.1 (http://www.googlebot.com/bot.html)'; $ch = curl_init(); 
curl_setopt($ch, CURLOPT_USERAGENT, $userAgent); curl_setopt($ch, 
CURLOPT_URL,$target_url); curl_setopt($ch, CURLOPT_FAILONERROR, true); 
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, 
CURLOPT_AUTOREFERER, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER,true); 
curl_setopt($ch, CURLOPT_TIMEOUT, 300); $html = curl_exec($ch); if (!$html) {   
 echo br /cURL error number: .curl_errno($ch);echo br /cURL error: 
. curl_error($ch);exit; } // Create DOM from URL or file $html = 
file_get_html('http://www.greenecountymo.org/sheriff/warrants.php?search=C'); 
// Find table foreach($html-find('table') as $table) {
foreach($table-find('tr') as $tr){ // Grab children
   $cells = $tr-children();  if($cells[0]-plaintext != 
Name){for ($i = 0; $i  count($cells); $i++)  
  {  switch ($i){ case 0: 
// Name $name = $cells[$i]-plaintext; 
echo $cells[$i]-plaintext; break; case 1: 
// Age $age = $cells[$i]-plaintext; 
break; case 2: // Warrant type $warrant = 
$cells[$i]-plaintext; break; case 3: // 
Bond amount $bond = $cells[$i]-plaintext;  
   break; case 4: // Warrant number 
$wnumber = $cells[$i]-plaintext; break; 
case 5: // Offence description $crime = 
$cells[$i]-plaintext; break; Default:  
   echo Uh-ohbr /; }
   }   }
// Build your INSERT statement here  $query = INSERT 
into warrants (wid, name, age, warrant, bond, wnumber, crime) VALUES (;
$query .=  '$wid', '$name', '$age', '$warrant', '$bond', '$wnumber', '$crime' 
);//$wid = mysql_insert_id();echo $query;  
  // run query mysql_query($query) or die (mysql_error());  
   }} ?



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Can this be done?

2009-05-05 Thread Maarten Schalekamp

can try the foreach, put all the urls in one array

something like this might work:

?php
include(inc/dbconn_open.php);
include(inc/dom.php);
error_reporting(E_ALL);
$TESTING = TRUE;
$targets[] = http://www.greenecountymo.org/sheriff/warrants.php;;
$targets[] = http://www.greenecountymo.org/sheriff/page2.php;;
$targets[] = http://www.greenecountymo.org/sheriff/page3.php;;
foreach ($targets as $target_url){
 $userAgent = 'Googlebot/2.1 (http://www.googlebot.com/bot.html)';
 $ch = curl_init(); curl_setopt($ch, CURLOPT_USERAGENT, $userAgent);
 curl_setopt($ch, CURLOPT_URL,$target_url);
 curl_setopt($ch, CURLOPT_FAILONERROR, true);
 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
 curl_setopt($ch, CURLOPT_AUTOREFERER, true);
 curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
 curl_setopt($ch, CURLOPT_TIMEOUT, 300);
 $html = curl_exec($ch); if (!$html) {
  echo br /cURL error number: .curl_errno($ch);
  echo br /cURL error: . curl_error($ch);
  exit;
 } // Create DOM from URL or file
 $html = 
file_get_html('http://www.greenecountymo.org/sheriff/warrants.php?search=C'); 
// Find table

 foreach($html-find('table') as $table) {
  foreach($table-find('tr') as $tr){ // Grab 
children

   $cells = $tr-children();
   if($cells[0]-plaintext != Name) {
for ($i = 0; $i  count($cells); $i++) {
 switch ($i){
  case 0: // Name
   $name = $cells[$i]-plaintext;
   echo $cells[$i]-plaintext;
   break;
  case 1: // Age
   $age = $cells[$i]-plaintext;
   break;
  case 2: // Warrant type
   $warrant = $cells[$i]-plaintext;
   break;
  case 3: // Bond amount
   $bond = $cells[$i]-plaintext;
   break;
  case 4: // Warrant number
   $wnumber = $cells[$i]-plaintext;
   break;
  case 5: // Offence description
   $crime = $cells[$i]-plaintext;
   break;
  Default:
   echo Uh-ohbr /;
   }   }
   }

   // Build your INSERT statement here
   $query = INSERT into warrants (wid, name, age, warrant, bond, wnumber, 
crime) VALUES (;
   $query .=  '$wid', '$name', '$age', '$warrant', '$bond', '$wnumber', 
'$crime' );

   //$wid = mysql_insert_id();
   echo $query;
   // run query
   mysql_query($query) or die (mysql_error());
  }
 }
}
?


Miller, Terion tmil...@springfi.gannett.com wrote in message 
news:c625aae1.e9b%kmille...@springfi.gannett.com...




On 5/5/09 8:31 AM, php news feed maarte...@scullix.co.za wrote:

post the script, and example of data

Miller, Terion tmil...@springfi.gannett.com wrote in message
news:c6259e7b.e91%kmille...@springfi.gannett.com...
Ok I have a script that grabs data from a page and puts it in a db, I need
to run this script 26 times on 26 different pages on the same site, is there
a way to do this without making 26 different scripts load? Should I post the
script?

Thanks,
T.Miller


__ Information from ESET Smart Security, version of virus signature
database 4053 (20090505) __

The message was checked by ESET Smart Security.

http://www.eset.com




__ Information from ESET Smart Security, version of virus signature 
database 4053 (20090505) __


The message was checked by ESET Smart Security.

http://www.eset.com




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Here is the script:
?php include(inc/dbconn_open.php); include(inc/dom.php); 
error_reporting(E_ALL); $TESTING = TRUE; $target_url = 
http://www.greenecountymo.org/sheriff/warrants.php;; $userAgent = 
'Googlebot/2.1 (http://www.googlebot.com/bot.html)'; $ch = curl_init(); 
curl_setopt($ch, CURLOPT_USERAGENT, $userAgent); curl_setopt($ch, 
CURLOPT_URL,$target_url); curl_setopt($ch, CURLOPT_FAILONERROR, true); 
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, 
CURLOPT_AUTOREFERER, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER,true); 
curl_setopt($ch, CURLOPT_TIMEOUT, 300); $html = curl_exec($ch); if (!$html) 
{echo br /cURL error number: .curl_errno($ch);echo br /cURL 
error: . curl_error($ch);exit; } // Create DOM from URL or file $html = 
file_get_html('http://www.greenecountymo.org/sheriff/warrants.php?search=C'); 
// Find table foreach($html-find('table') as $table) { 
foreach($table-find('tr') as $tr){ // Grab children 
$cells = $tr-children();  if($cells[0]-plaintext != 
Name){for ($i = 0; $i  count($cells); $i++) 
{  switch ($i){ case 0: // 
Name $name = $cells[$i]-plaintext; 
echo $cells[$i]-plaintext; break; case 
1: // Age $age = $cells[$i]-plaintext; 
break; case 2: // Warrant type $warrant 
= $cells[$i]-plaintext; break; case 3: 
// Bond amount 

Re: [PHP] Re: Can this be done?

2009-05-05 Thread Miller, Terion



On 5/5/09 8:47 AM, Maarten Schalekamp maarte...@scullix.co.za wrote:

$targets[] = http://www.greenecountymo.org/sheriff/warrants.php;;
 $targets[] = http://www.greenecountymo.org/sheriff/page2.php;;
 $targets[] = http://www.greenecountymo.org/sheriff/page3.php;;
 foreach ($targets as $target_url){

I think this is pointing me in the right direction, I put in a few of the urls, 
but got the blank page of php death.  I changed this part:

  $html =
file_get_html('http://www.greenecountymo.org/sheriff/warrants.php?search=C');

to:
  $html =
file_get_html('$target_url');  maybe this part is not done right?

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Can it be Done?

2002-10-06 Thread Sascha Cunz

To produce such a JavaScript:

define('_DOMBASE', 'http://yourdomain.com');

echo 'SCRIPT language=JavaScript type=text/javascript'.\n
.'if (document.location == top.location)'.\n
.'  top.location='._DOMBASE.'/index.php?goto='
   .base64_encode($_SERVER[REQUEST_URI]).';'.\n
.'/SCRIPT';

where the index.php works like:

? if (!isset($_GET['goto']))
 $goto = home.php; else
 $goto = base64_decode($_GET['goto']);
?
FRAMESET
  someframes
  FRAME src=http://yourdomain.com/? echo $goto; ?
/FRAMESET

As Stephen reported me recently, this also works with iframes.

Sascha

Am Sonntag, 6. Oktober 2002 21:37 schrieb Adriano:
 Hi people,

  Edwin wrore:
  'Not really sure, but perhaps, with Javascript.
 
  But I'd rather recommend you to give up iframes... ;)

 Can you post an example of Javascript code checking for _parent frame?
 By the way, what's wrong with iframes?
 bye,
 Adr


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Re: Can it be Done?

2002-10-06 Thread Adriano

I understand and thank you Sascha.
Curiosity: why do you use the 'base64_encode' function to send querystring
arguments? I'd rather used urlencode...

Sascha Cunz [EMAIL PROTECTED] ha scritto nel messaggio
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
To produce such a JavaScript:

define('_DOMBASE', 'http://yourdomain.com');

echo 'SCRIPT language=JavaScript type=text/javascript'.\n
.'if (document.location == top.location)'.\n
.'  top.location='._DOMBASE.'/index.php?goto='
   .base64_encode($_SERVER[REQUEST_URI]).';'.\n
.'/SCRIPT';

where the index.php works like:

? if (!isset($_GET['goto']))
 $goto = home.php; else
 $goto = base64_decode($_GET['goto']);
?
FRAMESET
  someframes
  FRAME src=http://yourdomain.com/? echo $goto; ?
/FRAMESET

As Stephen reported me recently, this also works with iframes.

Sascha

Am Sonntag, 6. Oktober 2002 21:37 schrieb Adriano:
 Hi people,

 @ Edwin wrore:
  'Not really sure, but perhaps, with Javascript.
 
  But I'd rather recommend you to give up iframes... ;)

 Can you post an example of Javascript code checking for _parent frame?
 By the way, what's wrong with iframes?
 bye,
 Adr




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Re: Can it be Done?

2002-10-06 Thread Sascha Cunz

should be interchangeable.

When i wrote this, i didn't want to show the real url up in browser, so i used 
base64 encoding.

Sascha

Am Sonntag, 6. Oktober 2002 23:52 schrieb Adriano:
 I understand and thank you Sascha.
 Curiosity: why do you use the 'base64_encode' function to send querystring
 arguments? I'd rather used urlencode...

 Sascha Cunz [EMAIL PROTECTED] ha scritto nel messaggio
 [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 To produce such a JavaScript:

 define('_DOMBASE', 'http://yourdomain.com');

 echo 'SCRIPT language=JavaScript type=text/javascript'.\n
 .'if (document.location == top.location)'.\n
 .'  top.location='._DOMBASE.'/index.php?goto='
.base64_encode($_SERVER[REQUEST_URI]).';'.\n
 .'/SCRIPT';

 where the index.php works like:

 ? if (!isset($_GET['goto']))
  $goto = home.php; else
  $goto = base64_decode($_GET['goto']);
 ?
 FRAMESET
   someframes
   FRAME src=http://yourdomain.com/? echo $goto; ?
 /FRAMESET

 As Stephen reported me recently, this also works with iframes.

 Sascha

 Am Sonntag, 6. Oktober 2002 21:37 schrieb Adriano:
  Hi people,
 
  @ Edwin wrore:
   'Not really sure, but perhaps, with Javascript.
  
   But I'd rather recommend you to give up iframes... ;)
 
  Can you post an example of Javascript code checking for _parent frame?
  By the way, what's wrong with iframes?
  bye,
  Adr


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php