Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Doing some tests with SoupStrainer
#1
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_crumble
how to implement this condition in the souStrainer-code-parser!?
Wordpress - super toolkits a. http://wpgear.org/ :: und b. https://github.com/miziomon/awesome-wordpress :: Awesome WordPress: A curated list of amazingly awesome WordPress resources and awesome python things https://github.com/vinta/awesome-python
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  SoupStrainer: example Truman 10 7,420 Sep-26-2018, 11:22 PM
Last Post: Truman

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020