Doing some tests with SoupStrainer - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Web Scraping & Web Development (https://python-forum.io/forum-13.html) +--- Thread: Doing some tests with SoupStrainer (/thread-33675.html) |
Doing some tests with SoupStrainer - apollo - May-16-2021 Hello dear pythonistas - hello dear python-experts, hope everything is all right and youre well. i am doing some tests with SoupStrainer import requests from bs4 import BeautifulSoup, SoupStrainer content = requests.get('https://www.google.com').content for link in BeautifulSoup(content, parse_only=SoupStrainer('a')): if hasattr(link, "href"): print(link['href'])note: i only want to have the links that are in bold tags all with a bold tag: <li><b><a href="linkitem_a.html">linkitem_a</a></b> {bla_bla_a} (bla_bla_a), apple_crumble </li> <li><a href="linkitem_b.html">linkitem_b</a> {bla_bla_b} (bla_bla_b), apple_crumble </li> <li><b><a href="linkitem_c.html">linkitem_c</a></b> {bla_bla_c} (bla_bla_c), apple_crumblehow to implement this condition in the souStrainer-code-parser!? |