Oct-22-2019, 01:43 PM
Hi guys,
How's it going?
I've been in weeks trying to remove a double-quote (") from a word (as I want to count the word in a certain text or webpage and what not).
Been going back and forth in changing the variable to list or string in order to use their methods.
Here's my code:
There would be words like:
“Stay with Me” and “I’m not the Only One”,
"Latch"
“The Thrill of It All”
“Oh! Carol”
etc. etc....
I cannot remove those double-quotes. Tried .replace, .strip, even if I .split them up or turn them into a list. I can remove other special characters like punctuation, apostrophe, period, etc. etc.... but never the double-quotes.
Pls. try the code and you'll get the output of all the article including those that I had mentioned.
Hope someone can help me as I am now very interested to what I am missing, to why I cannot remove them and have a clean list of only just words.
Thanks in advance!
How's it going?
I've been in weeks trying to remove a double-quote (") from a word (as I want to count the word in a certain text or webpage and what not).
Been going back and forth in changing the variable to list or string in order to use their methods.
Here's my code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
import requests from bs4 import BeautifulSoup r = requests.get(url) soup = BeautifulSoup(r.text, 'lxml' ) articles = soup.find( 'div' , class_ = "cmsmasters_text" ) paragraphs = articles.find_all( 'p' ) new_p = [] for p in paragraphs: new_p.append(p.get_text()) for p in new_p: print ( str (p).lstrip( '"' )) |
“Stay with Me” and “I’m not the Only One”,
"Latch"
“The Thrill of It All”
“Oh! Carol”
etc. etc....
I cannot remove those double-quotes. Tried .replace, .strip, even if I .split them up or turn them into a list. I can remove other special characters like punctuation, apostrophe, period, etc. etc.... but never the double-quotes.
Pls. try the code and you'll get the output of all the article including those that I had mentioned.
Hope someone can help me as I am now very interested to what I am missing, to why I cannot remove them and have a clean list of only just words.
Thanks in advance!