Hello,
I have HTML input to which I apply some changes.
Feature 1:
=======
I want to tranform all the text, but if the text is inside
an "a href" tag, I want to leave the text as it is.
The HTML is not necessarily well-formed, so
I would like to do that using BeautifulSoup (or
maybe another tolerant parser).
As a test case, suppose I want to uppercase all the text
except the text that is within "a href" tags:
ExampleString = """
<footag>Lorem Ipsum</footagis simply
dummy text of <a href="junk.html ">the printing</aand
<a href="junk2.htm l">typesetti ng <b>industry</b>.</a>
Thanks."""
When applying the text transform, I want to obtain:
<footag>LOREM IPSUM</footagIS SIMPLY
DUMMY TEXT OF <a href="junk.html ">the printing</aAND
<a href="junk2.htm l">typesetti ng <b>industry</b>.</a>
THANKS."""
Feature 2:
========
Another thing I may want to do: If the text I would normally
transform is inside an "a href" tag, then do not transform it,
but insert the result of text transformation just after the "</a>".
Using the same example as input, application of
this feature2 would give something like that:
<footag>LOREM IPSUM</footagIS SIMPLY
DUMMY TEXT OF <a href="junk.html ">the printing</a><feat2>THE
PRINTING</feat2AND
<a href="junk2.htm l">typesetti ng
<b>industry</b>.</a><feat2>TYPESE TTING <b>INDUSTRY</b>.</feat2>
THANKS."""
========
Thanks for your help 1 1257 vb******@gmail. com wrote:
Hello,
I have HTML input to which I apply some changes.
Feature 1:
=======
I want to tranform all the text, but if the text is inside
an "a href" tag, I want to leave the text as it is.
The HTML is not necessarily well-formed, so
I would like to do that using BeautifulSoup (or
maybe another tolerant parser).
<snip/>
Use the BeautifulSoup + XSL. Writing your two features in xsl is close to a
no-brainer, and it is certainly the best tool for the job.
And there are a few implementations for python available.
Diez This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Fazer |
last post by:
Hello,
I was wondering what would be the easiest way to strip away HTML tags from a string?
Or how would I remove everything between < and > also the < , > as well using regex?
Thanks for any help!
|
by: jjliu |
last post by:
Could someone tell me how to parse the inside of html tags by perl, such as
<meta> </meta>
<head> </head>
<title> </title>
.........
Thanks
|
by: jjliu |
last post by:
Could someone tell me how to remove all html tags (and anything inside tags)
by perl. Some people suggested me to use HTML::TagFilter but i could not
find window version. Thanks very much for your help.
JJL
|
by: A Hess |
last post by:
Today, my wife was chatting with a friend and her friend was telling her
about an irc script that she just "needed" and then directed her to this
download page: http://www.barrie44.pwp.blueyonder.co.uk/script.htm
I have IE all but removed from this computer and use Firebird. Needless
to say, the page barely even showed up and the lower half, including the
DL link is nowhere to be seen. After fighting with it a bit my wife and
her friend...
|
by: James Geurts |
last post by:
Hi all
Can someone help me out with a regex to remove all html tags except for <p>,</p>,<br>,<br/> from a string
Thank
Jim
| |
by: jay |
last post by:
Hi all,
Can someone help me out with a regex to remove all html tags, except
for links, from a string.
Thanks,
-Jay
|
by: Randall Parker |
last post by:
I want to generate an HTML tag that will look like:
<a href="EquipmentServiceCreate.aspx?serial=X01">Create New Service For X01</a>
or on a different instance where the user would be viewing "X05" it would looke like:
<a href="EquipmentServiceCreate.aspx?serial=X05">Create New Service For X05</a>
I'm trynig to figure out how to do that using HtmlGenericControl in C# code behind.
|
by: PythonistL |
last post by:
I have this script that scrolls the plain text.
<script type="text/javascript">
var msg = 'My scrolling text. ..';
var myTimeout;
function scrollMsg() {
document.getElementById('textScroll').innerHTML = msg;
msg = msg.substring(1,msg.length) + msg.substring(0,1);
myTimeout = setTimeout(scrollMsg, 200);
}
|
by: countocram |
last post by:
I have big problem, I'm using preg_replace() function for my highlighter function, after searching for particular keyword, once the hightler check box is checked it will highlight the content that matches the search keyword, the problem is, it also highlight the text inside the HTML tags that matches the keywords.
here's the screenshot:
http://www.fileden.com/files/2006/6/11/61581/screen.JPG
I need a preg_replace() function that will not...
|
by: jamieg99 |
last post by:
Hello,
I've got an object that's being converted into SAXSource and then converted into a pdf with FOP. Some of the data however is in HTML format inside the xml tags and is being escaped (>, etc) before it transformed.
I'd like to have this these html tags parsed as actual elements by the stylesheet, which would mean reading it in it's unescaped format, but I can't figure out how to do this. I have "disable-output-escaping" set in 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: 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: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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
|
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...
| | |