![]() |
Searching within tags
Quote:
This will save you the hassle of coming up with complex regular expressions. For example the following minimal plugin code: Spoiler:
will look for span tags with a Calibre13 class and replace them with <b> tags. (All other <span> tags will be deleted.) Before: Code:
<p>This should be <span class="Calibre6 Calibre13 Calibre2">bolded</span>. <span class="Calibre2">This span is redundant</span> <span>and this span should also be deleted.</span></p>Code:
<p>This should be <b>bolded</b>. This span is redundant and this span should also be deleted.</p>
|
Quote:
Only, I do need a little help with syntax to make this modified code work: Spoiler:
1. how to pass to soup.find_all() a list of tags as argument 2. how to rework Code:
if 'calibre' in tag['class']3. Would the code work as well for selecting <meta... /> tag by 'name' and deleting it? How? Maybe it's trivial, but I am green--python 2.+ for Gimp is the fartest I have gone. And couldn't make anything of your link :( Thanks! * Sorry for the delay: too many irons... ** Does this get 'out of topic'? (better in plug-ins) |
Quote:
Code:
tags = soup.find_all(['i', 'b', 'small', 'br'])Quote:
Quote:
Quote:
Quote:
|
| All times are GMT -4. The time now is 08:43 PM. |
Powered by: vBulletin
Copyright ©2000 - 3.8.5, Jelsoft Enterprises Ltd.
MobileRead.com is a privately owned, operated and funded community.