|
28-02-2009, 19:46
|
|
|
חבר מתאריך: 10.04.05
הודעות: 235
|
|
ניסיתי עם Curl וקיבלתי קוד מקור טהור בלי קוקיז ודברים שיכולים לעזור לי, יש אפשרות להוציא קוד מקור של דף עם כל הדברים הנלווים שהדפדפן עצמו מתחבר? לדוגמא אם אני רוצה להציג דף שיראה את ההודעות הפרטיות שלי בפרש.... שאני רק יכנס אליו, בלי להיכנס עם הדפדפן עצמו לפרש... מקווה שהבנתם אותי הנה הקוד שהתשמשתי בו:
קוד PHP:
<?php /** * Copyright (c) 2008, David R. Nadeau, NadeauSoftware.com. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following * disclaimer in the documentation and/or other materials provided * with the distribution. * * * Neither the names of David R. Nadeau or NadeauSoftware.com, nor * the names of its contributors may be used to endorse or promote * products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY * WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. */
/* * This is a BSD License approved by the Open Source Initiative (OSI). * See: http://www.opensource.org/licenses/bsd-license.php */
/** * Get a file on the web. The file may be an (X)HTML page, an image, etc. * Return an associative array containing the page header, contents, * and HTTP status code. * * Values in the returned array are as defined by the CURL curl_getinfo() * function, and include: * * "url" the last effective URL after redirects * "http_code" the last error/status code * "content_type" the content type from the header * * This function adds a few more: * * "content" the page content (text, image, etc.) * "errno" the CURL error code * "errmsg" the CURL error message * * On success, "errno" is 0, "http_code" is 200, and "content" has the * web page. * * On an error with the URL, such as a redirect limit, or timeout, * "errno" will be non-zero and "errmsg" will contain an error message. * There other fields will be missing. * * On an error with the web site, such as a missing page, no permissions, * or no service, "errno" will be 0, "http_code" will be the HTTP error * code, and "content" will be missing. * * Parameters: * url the URL of the page to get * * Return values: * An associative array containing the page text and error codes, * as described above. * * See also: * http://nadeausoftware.com/articles/2007/06/php_tip_how_get_web_page_using_curl */
function get_web_page( $url ) { $options = array( CURLOPT_RETURNTRANSFER => true, // return web page CURLOPT_HEADER => false, // don't return headers CURLOPT_FOLLOWLOCATION => true, // follow redirects CURLOPT_ENCODING => "", // handle compressed CURLOPT_USERAGENT => "spider", // who am i CURLOPT_AUTOREFERER => true, // set referer on redirect CURLOPT_CONNECTTIMEOUT => 120, // timeout on connect CURLOPT_TIMEOUT => 120, // timeout on response CURLOPT_MAXREDIRS => 10, // stop after 10 redirects );
$ch = curl_init( $url ); curl_setopt_array( $ch, $options ); $content = curl_exec( $ch ); $err = curl_errno( $ch ); $errmsg = curl_error( $ch ); $header = curl_getinfo( $ch ); curl_close( $ch );
$header['errno'] = $err; $header['errmsg'] = $errmsg; $header['content'] = $content; return $header; }
$url='http://www.fresh.co.il/vBulletin/usercp.php?'; $result = get_web_page( $url );
if ( $result['errno'] != 0 ){ echo "error: bad url, timeout, redirect loop ...";}
if ( $result['http_code'] != 200 ){ echo 'error: no page, no permissions, no service ...'; } else{ $page = $result['content']; echo $page; }
?>
_____________________________________
חתימתכם הוסרה כיוון שלא עמדה בחוקי האתר. לפרטים נוספים לחצו כאן. תוכלו לקבל עזרה להתאמת החתימה לחוקים בפורום חתימות וצלמיות.
|
|