- #/usr/bin/perl -w
-
use LWP::UserAgent;
-
use Time::HiRes qw(gettimeofday);
-
#use Crypt::SSLeay;
-
-
use strict;
-
-
print "Enter URL to Time GET request for... ";
-
my $host=<STDIN>;
-
chomp $host;
-
-
my $before=gettimeofday;
-
my $ua = LWP::UserAgent->new();
-
my $request = HTTP::Request->new('GET', "$host");
-
my $response = $ua->request($request);
-
my $elapsed=gettimeofday-$before;
-
print "ERROR: Bad URL\n" if($response->is_error);
-
my @content=split/\n/,$response->content;
-
print "Request took $elapsed seconds.\n";
-
my @title=grep /(?:title|TITLE)/, @content;
-
print "TITLE LINE: @title \n";
-
I'm using this script to see how fast it can get different pages.
I put www.thescripts.com as my page, www.thescripts.com
Enter URL to Time GET request for... ERROR: Bad URL
Request took 0.0080049037933 3496 seconds.
Why would it be a bad url?
7 1670 miller 1,089
Recognized Expert Top Contributor
www.thescripts. com is not a fully qualified url. You must specify the protocol:
http://www.thescripts. com
- Miller
Thanks for helping, but it still didn't work: http://www.thescripts.com
Enter URL to Time GET request for... ERROR: Bad URL
Request took 0.0084350109100 3418 seconds.
>Exit code: 0
miller 1,089
Recognized Expert Top Contributor
Read this: cpan lwptut
Namely the second section "The Basics of the LWP Class Model" will show you a better way to formatting you request. And much more importantly, it will show you how to get meaningful error messages.
- Miller
KevinADC 4,059
Recognized Expert Specialist
Well, you have told the script to print "Bad URL" regardless of what the real error is. The script works fine for me, but do have to shutdown my firewall first because I never figured out how to get a command line perl program to be allowed internet access while the firewall is turned on.
I don't need to turn my firewall off for it to work.
However, it turns out it requested pages at roughly 1500-2000ms.
I'm still finding it hard to believe, that perl requests pages slower than VB6?!?!
KevinADC 4,059
Recognized Expert Specialist
perl is really good at processing text, anything else it is not going to be the fastest solution for doing something. I am not a VB6 coder so I have no way to know why it is faster than perl in this specific situation. Perl does have to be compiled, so that right there will add time to the over all speed of execution.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Fran?ois-Xavier Testard-Vaillant |
last post by:
In a Perl script I want to send several http requests WITHOUT waiting
for the remote servers answer (i.e. just triggering http requests) and
without having to create lots of processes...
Thanks in advance
François-Xavier
|
by: Sure |
last post by:
Hello All,
I want to update a form using the LWP & HTTP method. It was
working fine when I am updating the values like this
$ua = LWP::UserAgent->new;
$url ='http://xxx.be/cgi-bin/viewauth/Tracking/TestProjectAgainInitialDevStory#edittable2';
use HTTP::Request::Common;
my $res = $ua->request(POST $url,
Content_Type =>'form-data',
|
by: Robert Oschler |
last post by:
I have an IMG element that I've been using to send messages back to my
server whenever certain item option choices are made by a visitor. I send
each message by forming a URL with various search arguments being used, and
then I use Javascript to se the IMG element's SRC property to the URL.
I have discovered, that if the visitor clicks multiple options quickly, IE
does not execute every URL request. It looks like it queues them and...
|
by: Henrik |
last post by:
Hi,
I am trying to read some industrial webservers using the HTTP/CGI webequest
like this:
wrs = (HttpWebRequest)WebRequest.Create(HTTP/CGI-string);
mwst = (HttpWebResponse wrs.GetResponse();
str = mwst.GetResponseStream();
This usually works fine but on some servers i get:
|
by: Kueishiong Tu |
last post by:
I have a .net window form application but I have to get
data from various web sites. How do I make Http request
(preferrably via post method) from a window form to get
the data from those web sites?
What namespace and dll do I have to include?
A walkthrough and coding example will be helpful.
...
| |
by: omantawy |
last post by:
Hi,
I have some legacy ASP web applications that use an unmanaged COM
component to connect to a third party application. The third part
application has moved to the managed code in the current release with
backward compatibility with the unmanaged code.
In the future releases, the vendor is going to drop backward
compatibility and as a result of that all our legacy ASP applications
will break.
|
by: AviCoh |
last post by:
Hi,
Let me start with the question and then describe my case :
Is there a way to read the raw contents of an HTTP request in PHP as a
stream (i.e. not get it all at once from Apache) ?
In my case I am implementing an API for my server side app. One of the
actions in the API allows the posting of binary contents as
application/octet-stream. The size of this binary contents can get up
to several MBs.
|
by: nkg1234567 |
last post by:
I'm trying to extract HTML from a website in the form of a string, and then I want to extract particular elements from the string using the substr function:
here is some sample code that I have thus far:
use HTTP::Request::Common;
use LWP::UserAgent;
use LWP::Simple;
$ua = LWP::UserAgent->new;
|
by: rpjanaka |
last post by:
Hi all,
I am using AJAX to submit a data from a web page, it is properly working on the local host (when test with the local machine it is ok).also when access from another machine the pages are properly lord. But when send data it gives an http request error.
The following is the error message. it include several suggestions, but i cant exactly deiced what it is.?
pls anyone can help me to find the reason for this...
ERROR
The...
|
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...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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...
|
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,...
|
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...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |