473,657 Members | 2,953 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Perl Help!!!

2 New Member
Hi!

I am new here so pardon me for my naivity! I have written this code for grabbing the text(only the text) for a URL(e.g www.msn.com) with Perl:

Expand|Select|Wrap|Line Numbers
  1.    use LWP:: UserAgent;
  2.     use HTTP::Request;
  3.  
  4.     sub get_url{
  5.  
  6.        my $url=shift;
  7.        my $ua=new LWP::UserAgent;
  8.        my $req=new HTTP::Request 'GET',$url;
  9.        $ua ->timeout(10);
  10.        my src = $ua ->request($req);
  11.        return $src->content unless (!$src ->is_success);
  12.        return 0;    }
  13.  
  14.    sub dehtml{
  15.  
  16.        my $src=shift;
  17.             $src=~ s/<.*?>//g;
  18.             $scr=~ s/<[^>]*>//g;
  19.  
  20.      print $src.    }
  21.  
  22. dehtml(get_url(http://www.msn.com/)); 
It works pretty well.
How can I also grab the text(only the text) of the links that URL(www.msn.com) has?

Thank u in advance for any help! :)
Mar 16 '06 #1
1 2411
eWish
971 Recognized Expert Contributor
Search CPAN for an HTML Parser. This is easily done with a module.

--Kevin
Nov 18 '07 #2

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

Similar topics

0
2145
by: blob | last post by:
Hi all, Below is my script that will be used to connect to a remote host and change my password automatically: =========================================== #!/usr/bin/perl use strict();
3
6544
by: dpackwood | last post by:
Hello, I have two different scripts that do pretty much the same thing. The main perl script is on Windows. It runs and in the middle of it, it then calls out another perl script that then should run on a Unix box I have. Both scripts run ok, except for the part when Windows try's to call out the Unix script. I have it set up where the Unix is mapped through a drive letter and can drop stuff into the Unix box. It is going through another...
3
3768
by: Hugz | last post by:
Hello, And Thank you for taking time to help me.Myself Hugz.I am new to perl and want to write my own Scripts.But i can't understand how perl "rename" function and "file locking" works. Actually i am running a WinME with ActivePerl 5.8.0, what i want to know is 1.What do you mean by "file creation (and deletion) is not atomic over NFS" ?
0
5236
by: gedsta | last post by:
Hi all I am a total noob and its my 2nd post, first of all thank you for letting me use these forums as a source of information, and hopefully once i get my head round perl i maybe able to help other noobs as well. Ok, my problem is: Windows Server 2003 Plesk for Windows 7.5.6 X-Cart Software (ecommerce solution)
2
2498
by: Monkey | last post by:
Hi, Just coming back to perl after some time off, I think I need to use the split funtion. I want to convert $username=FEL\matt.honston, to $username=matt.honston and remove or split the FEL\ from the string (yes I'm using the whoaim command in XP) I know I need to use the split function, but just can't to remember the syntax. Thanks,
5
5735
by: olaamussah | last post by:
Hi, i just started learning perl which i would use for my uni. project unfortunately. Well, this is a simple user login page i tried to create but i cant get it to work. Can someone please check this out. Corrections would be highly appreciated. The code: use strict; use CGI qw(:standard); use CGI::Carp qw(warningsToBrowser fatalsToBrowser); use DBI; $CGI::POST_MAX = 1024 * 1000; sub print_login_form($);
2
2010
by: akhilak | last post by:
Hi, I am using XPath to retrieve the node data from an XML file. I used the following code to extract the attribute data from the file. I manually entered the attribute name in the code and I am able to extract the data properly. But when I tried to read the attribute name into a variable and use this variablename instead of actual data it is giving me errors. Here is my XML file: <book> <authordata authorid="1">Name Author</authordata>...
4
1182
by: SANDY1722 | last post by:
I have a unix file: file contents: foo.text: s_map_test $$param_name_20070919112345 I want to extract only the 2nd part of the line, and write to new file - foo.out
4
1015
by: mohan705 | last post by:
Hi I want to search for columns start_dt and end_dt in all my tables ,wrote shell sript to find the list of tables .I am new to perl want to do it same in perl.Any help it would be appericiated for name in `cat list.txt` do tabname=`awk /CREATE TABLE /{table=$2; start=0; } /START_DT/ { start++ } /END_DT/ && start { print table }' "$name.sql"` echo $tabname
2
1781
by: sonu2die4 | last post by:
Hi , I want to connect to a server running 'Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production With the Partitioning, OLAP and Data Mining options' from Perl. I have the required modules. a) DBI-1.607.tar b) DBD-Oracle-1.22.tar I want to know which client version from Oracle should I use from a client machine running a solaris 10. Any help will be very much appreciated. Regards
0
8384
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
8302
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8820
Oralloy
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...
0
8718
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
8499
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
4150
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
4300
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1601
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.