473,779 Members | 1,867 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_t ime
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 5024
Rik
Shuan wrote:
I am getting this error. Can it be fixed by setting more than 60 for
the max_execution_t ime
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_a ll( $regionpattern, $pageContent, $categorylinks ))
{
for( $y = 0; $y < count( $categorylinks[ 1 ] ); $y++ ){

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

include( "pagecrawler.ph p" );
}
}
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_t ime
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_ex ecution_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_a ll( $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($catego rylinks[1] as $link){
$category_link= "http://www.mysite.com" .$link;
include( "pagecrawler.ph p" );//I'm still curious what this does....
}

Or if you do use capture 2:
if(preg_match_a ll( $regionpattern, $pageContent, $categorylinks,
PREG_SET_ORDER) ){
foreach($catego rylinks as $link){
$category_link= "http://www.mysite.com" .$link[1];
include( "pagecrawler.ph p" );//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_e xecution_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.comwro te in message
news:eb******** *************** ****@news2.tude lft.nl...
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
2922
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 processing and creating 500 thumbnails. Is there anything I can do to avoid this error? Thank you John
1
4004
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 out over 4000 emails. (Note that each email is customised so needs to be sent individually - not using Bcc). The application reported to have sent the 4000 emails successfully (it sends each one as part of a loop and then when completed gives a...
10
6873
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 time can take 2-3 minutes, but even though I have set the executionTimeout in web.config to a high number of seconds (2400), the request will still time out after 90 seconds. The user sees a Request timed out error. The app logs a ThreadAborted...
2
9600
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 second it appends the seconds to a file. I expected a timeout after 300 seconds, becouse apache is configured
12
1467
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 original. def maximum(lst): maxval = lst for i in xrange(1, len(lst)): v = lst
2
1652
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 service. The apache server is in a Win2000 server machine. Thank´s
3
17929
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?? (using Dev-C++ compiler) Please see task and attempt below: TASK : 1.8.1 Exercise 1A - Temperature tracker Write a program that tracks temperatures during an experiment that takes 24 hours. The user should input the temperature. This...
2
19189
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 communications. http://community.lokad.com/PhpSalesForecasting.ashx Yet, in shared hosting with short PHP execution timeouts, our script may not terminate (being killed by the web server). Our concern is not the timeout in itself, it's the...
2
3046
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 exceeded in auth.php on line 5 auth.php contains:
0
9636
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10138
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10074
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9930
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7485
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5373
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5503
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3632
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2869
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.