How to replace text in Beautiful Soup?

I am trying to use beautiful soup to return how many followers an account has on Repl. How do I trim some of the text that I don’t want to print?
Repl Link: https://replit.com/@vidhurmahajan/Repl-Follower-Finder#main.py

Hi @paninitrumpet thanks for your question. I love what you are doing here!

I’ve forked your Repl and added a few lines of code which I think will give you what you need. Let me know if I’ve misunderstood.

https://replit.com/@IanAtReplit/Repl-Follower-Finder

In short what I’ve done is to test each line of the output you were previously printing to the screen. If it contains the word “followers” I’m then extracting the number from the line of output and then printing this to the screen.

Hope it helps!

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.