Table of Contents
回复讨论(解决方案)

curl爬取超时

Jun 23, 2016 pm 01:49 PM
curl time out

用curl抓取别的网站时可以正常抓回来,但是对于http://www.fblife.com/这个网站就无能为力了,总是在抓回16K大小后就不再返回数据了,但是http状态返回码依旧是200,求高人指教


回复讨论(解决方案)

阿弥陀佛,施主,如果基础编程没能解决,发到这里也是一样的。

set_time_limit(0);

set_time_limit(0);


不是这原因吧?

@curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.0)");

把你的代码贴出来,
我这样:

<?php	$u="http://www.fblife.com/";	$h=curl_init();	curl_setopt($h, CURLOPT_URL, $u);	$s=curl_exec($h);	curl_close($h);	echo $s;?>
Copy after login

返回很正常呀,文件信息165.56K

这个在浏览器里访问这个页面是可以的,关键这个php我是在后台跑的,为啥在后台运行就不行呢

把你的代码贴出来,
我这样:
PHP code

    $h=curl_init();
    curl_setopt($h, CURLOPT_URL, $u);
    $s=curl_exec($h);
    curl_close($h);
    echo $s;
?>


返回很正常呀,文件信息165……

对这网站也无能为力啊  http://www.ydtuiguang.com/

不拥curl就行啊
set_time_limit(0);
var_dump(file_get_contents("http://www.ydtuiguang.com/"));

我的可以啊。你的报错了吗

对这网站也无能为力啊 http://www.ydtuiguang.com/

今天又试了下,把这段代码存为fblife.php文件,然后在windows命令行下执行php fblife.php是可以正常输出的,但是在linux环境下,运行php fblife.php,同样的命令却只能得到一部分,请问有谁知道这是linux系统的问题还是其他别的问题呢?
而且,linux下 wget "http://www.fblife.com/"执行这个命令也只能得到一部分 
$u="http://www.fblife.com/";
$h=curl_init();
curl_setopt($h, CURLOPT_URL, $u);
$s=curl_exec($h);
curl_close($h);
echo $s;
?>

$timeout=360;//设置超时时间
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT,$timeout);

不是这个问题-_-!!

$timeout=360;//设置超时时间
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT,$timeout);

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to realize the mutual conversion between CURL and python requests in python How to realize the mutual conversion between CURL and python requests in python May 03, 2023 pm 12:49 PM

Both curl and Pythonrequests are powerful tools for sending HTTP requests. While curl is a command-line tool that allows you to send requests directly from the terminal, Python's requests library provides a more programmatic way to send requests from Python code. The basic syntax for converting curl to Pythonrequestscurl command is as follows: curl[OPTIONS]URL When converting curl command to Python request, we need to convert the options and URL into Python code. Here is an example curlPOST command: curl-XPOST https://example.com/api

Tutorial on updating curl version under Linux! Tutorial on updating curl version under Linux! Mar 07, 2024 am 08:30 AM

To update the curl version under Linux, you can follow the steps below: Check the current curl version: First, you need to determine the curl version installed in the current system. Open a terminal and execute the following command: curl --version This command will display the current curl version information. Confirm available curl version: Before updating curl, you need to confirm the latest version available. You can visit curl's official website (curl.haxx.se) or related software sources to find the latest version of curl. Download the curl source code: Using curl or a browser, download the source code file for the curl version of your choice (usually .tar.gz or .tar.bz2

PHP8.1 released: Introducing curl for concurrent processing of multiple requests PHP8.1 released: Introducing curl for concurrent processing of multiple requests Jul 08, 2023 pm 09:13 PM

PHP8.1 released: Introducing curl for concurrent processing of multiple requests. Recently, PHP officially released the latest version of PHP8.1, which introduced an important feature: curl for concurrent processing of multiple requests. This new feature provides developers with a more efficient and flexible way to handle multiple HTTP requests, greatly improving performance and user experience. In previous versions, handling multiple requests often required creating multiple curl resources and using loops to send and receive data respectively. Although this method can achieve the purpose

How to solve Java thread interrupt timeout exception (ThreadInterruptedTimeoutExceotion) How to solve Java thread interrupt timeout exception (ThreadInterruptedTimeoutExceotion) Aug 18, 2023 pm 01:57 PM

How to solve the Java thread interrupt timeout exception (ThreadInterruptedTimeoutException). In Java multi-thread programming, we often encounter situations where the thread execution time is too long. In order to prevent threads from occupying too many system resources, we usually set a timeout. When the thread execution time exceeds the timeout, we hope to be able to interrupt the execution of the thread. Java provides a thread interruption mechanism. By calling the thread's interrupt() method, you can

How does Meituan pay for overtime? Meituan's overtime compensation standards! How does Meituan pay for overtime? Meituan's overtime compensation standards! Mar 16, 2024 pm 07:55 PM

1. How will Meituan compensate for overtime? Meituan’s overtime compensation standards! Meituan’s overtime compensation rules are as follows: (1) Overtime when purchasing the Punctual Service: After selecting the Punctual Service, if the delivery rider fails to deliver on time, the system will automatically start the compensation process, and the amount of compensation will be determined based on the order details and the overtime duration. . (2) Ordinary timeout for non-purchased punctual products: 1. If the actual delivery time of the order is more than 10 minutes but less than 20 minutes later than the promised delivery time, 25% of the actual payment amount of the order will be compensated. 2. If the actual delivery time of the order is more than 20 minutes or less than 30 minutes later than the promised delivery time, 30% of the actual payment amount of the order will be compensated. 3. If the actual delivery time of the order is more than 30 minutes later than the promised delivery time, 50% of the actual payment amount of the order will be compensated. 4

From start to finish: How to use php extension cURL to make HTTP requests From start to finish: How to use php extension cURL to make HTTP requests Jul 29, 2023 pm 05:07 PM

From start to finish: How to use php extension cURL for HTTP requests Introduction: In web development, it is often necessary to communicate with third-party APIs or other remote servers. Using cURL to make HTTP requests is a common and powerful way. This article will introduce how to use PHP to extend cURL to perform HTTP requests, and provide some practical code examples. 1. Preparation First, make sure that php has the cURL extension installed. You can execute php-m|grepcurl on the command line to check

what is linux curl what is linux curl Apr 20, 2023 pm 05:05 PM

In Linux, curl is a very practical tool for transferring data to and from the server. It is a file transfer tool that uses URL rules to work under the command line; it supports file upload and download, and is a comprehensive transfer tool. . Curl provides a lot of very useful functions, including proxy access, user authentication, ftp upload and download, HTTP POST, SSL connection, cookie support, breakpoint resume and so on.

Lock wait timeout exceeded; try restarting transaction - How to solve MySQL error: transaction wait timeout Lock wait timeout exceeded; try restarting transaction - How to solve MySQL error: transaction wait timeout Oct 05, 2023 am 08:46 AM

Lockwaittimeoutexceeded;tryrestartingtransaction - How to solve the MySQL error: transaction wait timeout. When using the MySQL database, you may sometimes encounter a common error: Lockwaittimeoutexceeded;tryrestartingtransaction. This error indicates that the transaction wait timeout. This error usually occurs when

See all articles