473,804 Members | 2,147 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Substitution using regular expressions and mechanize

1 New Member
Basically I have a local html file, called file1.html it has a series of links (with a particular domain name) in addition to the html code, I am trying to follow each of these links (based on the regular expression /on\.fe/) each of these links, in their content have a link to another page, (I would like to capture this particular page based on a regular expression /www\.arax/), and substitute for each link (with regular expression /on\.fe/)in file1.html with their corresponding link (with regular expression/www\.arax/) So far this is what I have come up with, and am a little stuck

#! perl\bin\perl

use strict;
use warnings;
use WWW::Mechanize;

my $mech = WWW::Mechanize->new();

open(FILE, "< file1.html") || print "Unable to open the file file1 \n"
+;

while (<FILE>)
{
if($_ =~ /on\.fe/)
{
my $url = $_;
print $mech->uri."\n";
$mech->get($_);
$mech->content();
if($mech->content()=~ /www\.arax/)
{
my $url2 = $mech->content() =~ /www\.arax/;
print $mech->uri."\n";
s/$url/$url2/;
print;

}

}

}


close(FILE);
Dec 23 '06 #1
1 2313
GunnarH
83 New Member
You are multi-posting.
http://groups.google.com/group/comp....9efeabf5d61fb1

Please read here why that is bad:
http://lipas.uwasa.fi/~ts/http/crospost.html
Dec 25 '06 #2

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

Similar topics

6
1772
by: Lukas Holcik | last post by:
Hi Python crazies!:)) There is a problem to be solved. I have a text and I have to parse it using a lot of regular expressions. In (lin)u(ni)x I could write in bash: cat file | sed 's/../../' | sed 's/../../' .. .. .. > parsed_file I write a parser in python and what I must do is: regexp = re.compile(..)
4
5187
by: Együd Csaba | last post by:
Hi All, I'd like to "compress" the following two filter expressions into one - assuming that it makes sense regarding query execution performance. .... where (adate LIKE "2004.01.10 __:30" or adate LIKE "2004.01.10 __:15") .... into something like this: .... where adate LIKE "2004.01.10 __:(30/15)" ...
2
2015
by: comp.lang.php | last post by:
I am trying to replace within the HTML string $html the following: With Where I'm replacing "action=move_image" with "action=<?= $_REQUEST ?>"
1
1375
by: rs1975in | last post by:
I need one help regarding regular expressions in PERL I have a string like test,tesst11*,rohit I need to write a regular expression for substitution which will make this string like test tesst11* rohit
1
4389
by: Allan Ebdrup | last post by:
I have a dynamic list of regular expressions, the expressions don't change very often but they can change. And I have a single string that I want to match the regular expressions against and find the first regular expression that matches the string. I've gor the regular expressions ordered so that the highest priority is first (if two or more regular expressions match the string I want the first one returned) The code that does this has...
6
6337
by: Generic Usenet Account | last post by:
I was extremely surprised to learn that the extremely rich C++ string API does not have even a single menthod devoted to string substitution i.e. given a string, replace all instances of pattern-1 in the string with pattern-2. There are API methods for finding and replacing, but none on pattern substitution. Although I have developed an implementation for this (posted to the comp.sources.d newsgroup), does anyone have the background why...
7
1670
by: Samuel | last post by:
Hi, How would you implement a simple parser for the following string: --- In this string $variable1 is substituted, while \$variable2 is not. --- I know how to write a parser, but I am looking for an elegant (and lazy) way. Any idea?
1
3952
by: comeshopcheap | last post by:
Hi I am using this script to access doba.com (I need to download some files) but I keep on being sent back to the login page not the user home page. Any help. I think I may need to use a post method and opener is using a get method Thanks import mechanize
1
2240
by: tedpottel | last post by:
Hi, I can read the home page using the mechanize lib. Is there a way to load in web pages using filename.html instad of servername/ filename.html. Lots of time the links just have the file name. I'm trying to read in the links name and then vsit those pages. here is the sample code I am ussing.
0
9711
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
10595
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
10088
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
7633
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
6862
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();...
0
5668
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4306
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
3831
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3001
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.