Python Forum
please help me remove error for string.strip()
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
please help me remove error for string.strip()
#4
Look at a in:

for a in soup.find_all("h3"):
    job_heading.append(a.string.strip())
If you look at type(a) you get:

Quote:>>> type(a)
<class 'bs4.element.Tag'>

Dunno what that is, but is not a string and probably that's why you can't .strip() it: no string.

snippsat is the guy to ask with bs4 but I got this from here and saved it:

# Can be a list of tags
# tags = ['h3']
# for tags in soup.find_all(tags):
for tags in soup.find_all('h3'):
    print(tags.text.strip())

# or like this
for tags in soup.find_all('span'):
    print(tags.text.strip())
Reply


Messages In This Thread
RE: please help me remove error for string.strip() - by Pedroski55 - Oct-14-2022, 07:48 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  remove gilberishs from a "string" kucingkembar 2 284 Mar-15-2024, 08:51 AM
Last Post: kucingkembar
  extract only text strip byte array Pir8Radio 7 3,003 Nov-29-2022, 10:24 PM
Last Post: Pir8Radio
  Remove a space between a string and variable in print sie 5 1,810 Jul-27-2022, 02:36 PM
Last Post: deanhystad
  How do I remove spurious "." from a string? Zuhan 7 2,071 Apr-12-2022, 02:06 PM
Last Post: Pedroski55
  Can't strip extra characters from Data Canflyguy 7 1,880 Jan-10-2022, 02:16 PM
Last Post: Canflyguy
  strip() pprod 8 3,480 Feb-16-2021, 01:11 PM
Last Post: buran
  How to remove char from string?? ridgerunnersjw 2 2,575 Sep-30-2020, 03:49 PM
Last Post: ridgerunnersjw
  Remove from end of string up to and including some character lbtdne 2 2,357 May-17-2020, 09:24 AM
Last Post: menator01
  Remove escape characters / Unicode characters from string DreamingInsanity 5 13,794 May-15-2020, 01:37 PM
Last Post: snippsat
  Need help with code for my WS2812B (Neopixel) Led Strip Phibbl 1 2,777 Apr-08-2020, 07:18 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

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