473,406 Members | 2,352 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,406 software developers and data experts.

I need to stop the get method process its take more than 60 sec.

Hi All,

I used LWP::USerAgent module to get the data from the URL. If the URL get slow or some other reason to take the data more than 60 seconds need to exit from the method.

Is there any way to quit the method while get method processing more than 60 seconds.

Regards,
Ram.

I used the below code to get the data's from URL.

Expand|Select|Wrap|Line Numbers
  1. use warnings;
  2.     use strict;
  3.     use LWP::UserAgent;
  4.     use HTTP::Request;
  5.     use HTTP::Cookies;
  6.         my $inurl = "http://www.tcsonline.co.uk/Vessel_Schedule.asp";
  7.  
  8.     my $ua=LWP::UserAgent->new;
  9.     $ua->agent("User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:8.0.1) Gecko/20100101 Firefox/8.0.1");
  10.  
  11.     my $cookie= HTTP::Cookies->new(file=>"$0.txt",autosave => 1,);
  12.     $ua->cookie_jar($cookie);
  13.     $ua->timeout(0);
  14.     my $req=HTTP::Request->new(GET=>"$inurl");
  15.     $req->header("User-Agent" => "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 ( .NET4.0E)");
  16.     $req->header("Content-Type" => "text/html");
  17.  
  18.     my $res=$ua->request($req);
  19.     $cookie->extract_cookies($res);
  20.     $cookie->save;
  21.     $cookie->add_cookie_header($req);
  22.     my $code=$res->code;
  23.     my $page_content;
  24.     if($code=~m/20/is)
  25.     {        
  26.     $page_content=$res->content();
  27.  
  28.     }
  29.     open OUToutfile, ">Vessel.txt";
  30.     print OUToutfile $page_content;
  31.     close OUToutfile;
Jun 25 '12 #1
1 1969
numberwhun
3,509 Expert Mod 2GB
Please be sure and always read the documentation for the modules you are using. If you check that link, you will see there is a timeout for the constructor method.

Regards,

Jeff
Jun 25 '12 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Tom | last post by:
A Java applet has two methods stop() and destroy() that get called when the user moves to a different page. Does javascript have anything similar? thanks tom
0
by: strangedub | last post by:
I am working on a C# Windows program that needs to kill a known process. I have written code that works in development mode but hits an "Access Denied" exception when running the compiled program:...
3
by: Sunny | last post by:
Hi All I am creating a C# app, in which there are some methods that are considerably longer than the others and take a few minutes to complete, I want to give the users an option to stop that method...
2
by: Chan | last post by:
If i call invalidate() two times, how can I stop the process for some time between them? that is, do updating ----> invalidate() -->do updating----> pause--> invalidate() I update my data in my...
14
by: Harry Keck | last post by:
I have client side code that uses xmlhttp to make an asyncronous call to the server. This call really churns the server and can take a couple of minutes to finish. I have found that while this...
1
friendjin
by: friendjin | last post by:
Thanks in advance; Can I ask a question about VC++.NET 2003. about using window form application. when I click button1, the programming will be run, and the results will be displayed in...
3
by: ebcouv | last post by:
I need to stop a process that is started by an add-in for Excel. I want to do this with VB code (without having to open Taskmaster). Can someone please show me the code to do this???? THANKS...
3
by: shimajavar | last post by:
Hi all I have the following code: a line is growing up by clicking on "up" button, it has another button"start" which I want it to stop the process of growing the line...How can I make a button to...
0
by: Benjamins via AccessMonster.com | last post by:
The microsoft jet database engine stop the process because you and another user are attempting to change the same data. The system produce this error message when i run a certain form. It will...
4
by: Jonathan | last post by:
I have a SQL stored procedure for adding a new record in a transactions table. It also has two return values: CounterID and IDKey. I want to create a webservice that accepts the 10 input...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...

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.