Get webpage title with this perl script and why perl?

It’s a tough luck with Google scripts, getting page title, as in content within the page <title> tag. The script wouldn’t get all the titles for a list of URLs. Same with the Excel, a macro function as well is unable to get all the titles.It would hang up or freeze and doesn’t get titles for all the URLs on a column. If you are working on a search engine optimization, doing some analysis on page link and its title, you want the process to be quick and smooth. Unfortunately Google scripts and Excel macros can’t do this for you. This is why perl comes into the picture. You can as well use the python or a ruby script. But let me show you a tiny snippet of code that can help accomplish this task quite quickly without any hiccups along the way.

The perl script I use to fetch titles for a list of URLs on a text file is, shown below,

 

And the way to execute this script is, C:\perl\bin\ perl your_script_name.pl output.txt

The path where your script resides will be the path you run the script from, for example my script resides at C:\perl\bin\
It’s also the same path where your input.txt or whatever you want to call it resides. This text file has all the list of URLs one per line. The output.txt doesn’t have to be there, it will be generated automatically for you if one doesn’t exists already.

You perl script’s content will be the code above.

If you don’t have perl already on your computer, you can get it from here. It’s the Activestate’s ActivePerl.

Leave a Reply

Your email address will not be published. Required fields are marked *