473,394 Members | 1,721 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

preg_match_all Maximum execution time of 60 seconds error

I am getting this error. Can it be fixed by setting more than 60 for the
max_execution_time
in php.in file?

Fatal error: Maximum execution time of 60 seconds exceeded in
categorycrawler.php on line 19

on this line i have regular expression

preg_match_all(,,)
Aug 17 '06 #1
9 4990
Rik
Shuan wrote:
I am getting this error. Can it be fixed by setting more than 60 for
the max_execution_time
in php.in file?

Fatal error: Maximum execution time of 60 seconds exceeded in
categorycrawler.php on line 19

on this line i have regular expression

preg_match_all(,,)
Possibly. It's quite impossible to know without knowing your actual code. 60
second is really quite long. What are you trying to do exactly?

Grtz,
--
Rik Wasmus
Aug 17 '06 #2
I am trying to grab sites like craigslist, parse with regular expression
and put some content into database.

$request -fetch( $region_link );

if( !$request -error ){
$pageContent = $request -results;

$regionpattern =
"/<a[^>]*href=\"(\/s\/SL\/sg_maY.*)\".*>.*<img.*alt=\"(.*)\".*id=\"btn.*\">/
siU";

if(preg_match_all( $regionpattern, $pageContent, $categorylinks ))
{
for( $y = 0; $y < count( $categorylinks[ 1 ] ); $y++ ){

$category_link="http://www.mysite.com".$categorylinks[ 1 ][ $y ];

include( "pagecrawler.php" );
}
}
Aug 17 '06 #3
*** Shuan escribió/wrote (Thu, 17 Aug 2006 21:22:04 GMT):
I am getting this error. Can it be fixed by setting more than 60 for the
max_execution_time
in php.in file?
It's okay if you're doing a job that really needs a long time to execute,
such us retriving a 50 MB file from the Internet, spidering a web site or
synchronising two databases.

Is that the case?

--
-+ http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
++ Mi sitio sobre programación web: http://bits.demogracia.com
+- Mi web de humor con rayos UVA: http://www.demogracia.com
--
Aug 17 '06 #4
*** Shuan escribió/wrote (Thu, 17 Aug 2006 21:35:19 GMT):
I am trying to grab sites like craigslist, parse with regular expression
and put some content into database.
Try something like this:

ini_set('max_execution_time', 3600); // 1 hour
--
-+ http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
++ Mi sitio sobre programación web: http://bits.demogracia.com
+- Mi web de humor con rayos UVA: http://www.demogracia.com
--
Aug 17 '06 #5
Rik
Shuan wrote:
I am trying to grab sites like craigslist, parse with regular
expression and put some content into database.

$request -fetch( $region_link );

if( !$request -error ){
$pageContent = $request -results;

$regionpattern =
"/<a[^>]*href=\"(\/s\/SL\/sg_maY.*)\".*>.*<img.*alt=\"(.*)\".*id=\"btn.*\">/
siU";

if(preg_match_all( $regionpattern, $pageContent, $categorylinks ))
I was almost tempted to say it was a greedyness issue, before I spotted the /U.
Dodged a bullet there :-).

If I interprete you regex correctly, try this rewrite (I tend to use dots very
sparingly, I'm more a fan of negative character classes, in which proper
greediness is more usefull). I'm not really sure it will gain much on the
resources consumption, but we can try:

'|<a[^>]*?href="(/s/SL/sg_maY[^"]*)"[^>]*>.*?<img[^>]*?alt="([^"]*)"[^>]*?id="bt
n[^"]*"[^>]*>|si

I'd suggest a foreach loop also, instead your for loop:

foreach($categorylinks[1] as $link){
$category_link="http://www.mysite.com".$link;
include( "pagecrawler.php" );//I'm still curious what this does....
}

Or if you do use capture 2:
if(preg_match_all( $regionpattern, $pageContent, $categorylinks,
PREG_SET_ORDER)){
foreach($categorylinks as $link){
$category_link="http://www.mysite.com".$link[1];
include( "pagecrawler.php" );//I'm still curious what this does....
}
}

If you still have issues I'd like to see/know the actual site you're leeching
right now :-).(If you're trying to get a page all at once, be sure to unset()
unused/past variables.) I don't know what your actual pagecrawler.php does, but
if it doesn't use capture 2 you might as well not capture it.

Grtz,
--
Rik Wasmus
Aug 17 '06 #6
It's okay if you're doing a job that really needs a long time to execute,
such us retriving a 50 MB file from the Internet, spidering a web site or
synchronising two databases.

Is that the case?
i don't have to get a big file but i need to crawl the whole websites( about
1000 pages )
and that takes time;


Aug 17 '06 #7
Rik
Shuan wrote:
>It's okay if you're doing a job that really needs a long time to
execute, such us retriving a 50 MB file from the Internet, spidering
a web site or synchronising two databases.

Is that the case?

i don't have to get a big file but i need to crawl the whole
websites( about 1000 pages )
and that takes time;
Well yeah, about a 1000 pages will almost certainly need more execution time,
forget what I said about the regex. As the preg_match_all is likely the most
time consuming part of your script (be it relativelyy fast), chances are quite
high that in it's nth execution the limit is passed.

DO you know how many pages you do parse in those 60 second BTW?

Grtz,
--
Rik Wasmus
Aug 17 '06 #8
Shuan wrote:
I am trying to grab sites like craigslist, parse with regular expression
and put some content into database.

$request -fetch( $region_link );

if( !$request -error ){
$pageContent = $request -results;

$regionpattern =
"/<a[^>]*href=\"(\/s\/SL\/sg_maY.*)\".*>.*<img.*alt=\"(.*)\".*id=\"btn.*\">/
siU";
There is a lot of back-tracking in your pattern, even though you've
specified ungreedy behavior. If there are many instances matching the
<a[^>]*href=\"(\/s\/SL\/sg_maY part of the pattern but not the rest,
then the .* that follows would make the regexp engine continually scan
to the end of the file.

My suggestion is to do /<a\s+href=\"(\/s\/SL\/sg_maY.*)\">(.*)<\/a>/siU
first, then loop through the results and regexp for the img tag.

Aug 17 '06 #9
Hi,
>ini_set('max_execution_time', 3600); // 1 hour
This solution worked, but I need to check out the reg. expression
to see if i am doing it effiiciently.

Thanks all for your supports.

--
-+ http://alvaro.es - Alvaro G. Vicario - Burgos, Spain
++ Mi sitio sobre programacion web: http://bits.demogracia.com
+- Mi web de humor con rayos UVA: http://www.demogracia.com
"Rik" <lu************@hotmail.comwrote in message
news:eb***************************@news2.tudelft.n l...
Shuan wrote:
It's okay if you're doing a job that really needs a long time to
execute, such us retriving a 50 MB file from the Internet, spidering
a web site or synchronising two databases.

Is that the case?
i don't have to get a big file but i need to crawl the whole
websites( about 1000 pages )
and that takes time;

Well yeah, about a 1000 pages will almost certainly need more execution
time,
forget what I said about the regex. As the preg_match_all is likely the
most
time consuming part of your script (be it relativelyy fast), chances are
quite
high that in it's nth execution the limit is passed.

DO you know how many pages you do parse in those 60 second BTW?

Grtz,
--
Rik Wasmus


Aug 18 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: John | last post by:
I am trying to create thumbnails from 2500 pictures. But I always get a Maximum execution time of 30 seconds exceeded" at the statement with the method with imagejpeg or imagedestroy after...
1
by: Dave Smithz | last post by:
Hi, My PHP application for a client uses the publicly available "PHPMailer - PHP email class" which is very good. However, my client recently complained about the following error when sending...
10
by: greenb | last post by:
Our asp.net web app uses a .NET component (DLL) in the bin directory to call several stored procedures back to back to perform updates. They don't return any data. Sometimes the total execution...
2
by: hakim | last post by:
Hi NG, I have my own apache server 2.0.54 running with php 4.3.10. I got a little logical problem here about http requests. I have written a small php script which waits for x seconds. Every...
12
by: Steve R. Hastings | last post by:
I was looking at a Python function to find the maximum from a list. The original was more complicated; I simplified it. The built-in max() function can replace the simplified example, but not the...
2
by: ivancasher | last post by:
I´ve this warning in a php page "Maximum execution time of 30 seconds exceeded ", I´ve configurated the php.in, setting the value of max_execution_time = 1200, and then i restart the apache...
3
by: Madmartigan | last post by:
Hello I have the following task but am battling with the final output. How do I keep two different vectors in sync and how would I retrieve the index for the maximum value of one of the vectors??...
2
by: Joannes Vermorel | last post by:
We have developed an open-source eCommerce sales forecasting add-on in PHP (see link below) that requires usually more than a few seconds to complete because the process involves some Web Services...
2
by: Richard | last post by:
Hello all, I am looking into issues with time-outs on a website. These appear to happen in a random way for some users. This is one example: Fatal error: Maximum execution time of 60 seconds...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.