View Single Post
Old 04-06-2020, 10:45 AM   #3
Doitsu
Grand Sorcerer
Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.
 
Doitsu's Avatar
 
Posts: 5,731
Karma: 24031401
Join Date: Dec 2010
Device: Kindle PW2
Quote:
Originally Posted by carmenchu View Post
1. how to pass to soup.find_all() a list of tags as argument
You can use a list as the search parameter. For example:
Code:
tags = soup.find_all(['i', 'b', 'small', 'br'])
Quote:
Originally Posted by carmenchu View Post
2. how to rework
Code:
if 'calibre' in tag['class']
so that it would match a substring, i.e., 'calibre15'.
You can use a regular expression with find_all().

Quote:
Originally Posted by carmenchu View Post
3. Would the code work as well for selecting <meta... /> tag by 'name'
Yes, they're treated like all other tags.

Quote:
Originally Posted by carmenchu View Post
[...]and deleting it? How?
You can delete tags with decompose(). However, since this modifies the "soup," it should be done last.

Quote:
Originally Posted by carmenchu View Post
** Does this get 'out of topic'? (better in plug-ins)
I also think it should be moved to plugins.
Doitsu is offline   Reply With Quote