Re: [PHP] Re: Can this be done?
On 5/5/09 8:47 AM, "Maarten Schalekamp" 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 this be done?
can try the foreach, put all the urls in one array something like this might work: 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 "cURL error number:" .curl_errno($ch); echo "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-oh"; } } } // 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"" wrote in message news:c625aae1.e9b%kmille...@springfi.gannett.com... On 5/5/09 8:31 AM, "php news feed" wrote: post the script, and example of data ""Miller, Terion"" 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: 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 "cURL error number:" .curl_errno($ch);echo "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 $cri
Re: [PHP] Re: Can this be done?
On 5/5/09 8:31 AM, "php news feed" wrote: post the script, and example of data ""Miller, Terion"" 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: 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 "cURL error number:" .curl_errno($ch);echo "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-oh"; } } } // 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
[PHP] Re: Can this be done?
post the script, and example of data ""Miller, Terion"" 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
[PHP] Re: Can this be done with mail()?
> >I need to query a database and return a resultset. A php script will then >sort through the data and send the data to the browser in the form of a table. > >Is it possible to gather the the results with html tags and store them in a >variable so that the results can be emailed to someone? If so, how would >this be done? Do as much of the sorting/searching in SQL as you can. MUCH faster. Use the mail class from http://phpclasses.org to do the html-enhanced email. WARNING: Many readers will simply *TRASH* your "enhanced" email. Re-think your priorities. Collecting your HTML in a variable is easy: \n"; # Loop through results{ $html .= "$x$y$z\n"; } $html .= "\n"; ?> It's just like doing everything with "echo", only not. :-) You may want to echo some stuff out as well, so you know what's happening... -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Can this be done with mail()?
Yes. I'm sure you could just mail out the table in an email. You'd have to do it as a multipart email (i think that's what it's called) as just mailing out the html code wouldn't show as a table in a mail client. Here's the source of a HTML spam I got this morning - should give you an idea how to do it. Note: you still mail out using the mail() function. Received: from xmail02.nationala-1advertising.com ([208.236.10.104]) by mc2-f11.law16.hotmail.com with Microsoft SMTPSVC(5.0.2195.4905); Sat, 13 Jul 2002 02:38:25 -0700 Received: (qmail 22574 invoked from network); 12 Jul 2002 23:51:55 - Received: from unknown (HELO CAMPAIGN) (208.236.10.4) by 0 with SMTP; 12 Jul 2002 23:51:55 - From: AccuLotto <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Subject: WIN $10,000 in 6 months - Guaranteed! [EMAIL PROTECTED] Date: Fri, 12 Jul 2002 19:54:23 -0700 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="Boundary.." Return-Path: [EMAIL PROTECTED] Message-ID: <[EMAIL PROTECTED]> X-OriginalArrivalTime: 13 Jul 2002 09:38:25.0416 (UTC) FILETIME=[09287880:01C22A51] --Boundary.. Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit This message can only be viewed in HTML --Boundary.. Content-Type: text/html; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit http://www.acculotto.com/p.pl/M2"; TARGET="_blank"> http://208.236.11.23/custom/acculotto/images/acculotto.gif"; BORDER="0"> If the above links do not work or appear, simply copy this URL and paste it into your browser's address field: http://www.acculotto.com/p.pl/M2"; TARGET="_blank"> http://www.acculotto.com/p.pl/M2 Note: This email was sent to you because you registered at Free.com and subscribed to this newsletter. The email address was then verified and the agreement confirmed by someone responding from your email address that required confirmation of registration. This is a double opt-in list and can NOT in any way be construed as spam. If you wish to unsubscribe from Free.com, please click the link below: http://www.Free.com/OptOut.asp?o=227825";>Unsubscribe Here and you will never receive another wonderful, free offer from us! Please note, it may take up to a week for you to be removed from our database. --Boundary..-- "Manuel" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > > I need to query a database and return a resultset. A php script will then sort through the data and send the data to the browser in the form of a table. > > Is it possible to gather the the results with html tags and store them in a variable so that the results can be emailed to someone? If so, how would this be done? > > > > - > Do You Yahoo!? > Yahoo! Autos - Get free new car price quotes -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Can this be done in PHP?
Mmm - looks damn complex but it's really very simple - Get yourself a copy of phpAdsNew (from sourceforge.net) - It's an amazing banner thingy with all sorts of tricks for display adverts (text, graphics, flash, iframes, frames, layers, etc) and it's well documentated. Ed Lazor <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > I'm trying to understand how this banner exchange works and whether it can > be done in PHP. Here's the HTML you put on your web page: > > href="http://rpgx.rpgconsortium.com/xchange/engage.cgi?advert=NonSSI&page=XX > "> src="http://rpgx.rpgconsortium.com/xchange/engage.cgi?id=atfantasy&page=01"; > border="0" width="468" height="60"> > > > It... > - displays a random banner image > - takes you to the site relating to the displayed image > > How does it do that? Any ideas on how to do this in PHP? > > -Ed > > > > This message is intended for the sole use of the individual and entity to > whom it is addressed, and may contain information that is privileged, > confidential and exempt from disclosure under applicable law. If you are > not the intended addressee, nor authorized to receive for the intended > addressee, you are hereby notified that you may not use, copy, disclose or > distribute to anyone the message or any information contained in the > message. If you have received this message in error, please immediately > advise the sender by reply email and delete the message. Thank you very > much. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]