I am unable to get the text inside the p tags i want text of all the p tags, have tried this so far but unable to exact text.
JavaScript
x
11
11
1
import requests
2
from bs4 import BeautifulSoup
3
4
link = 'https://trumpwhitehouse.archives.gov/briefings
5
statements/remarks-president-trump-farewell-address-nation/'
6
7
page = requests.get(link)
8
soup = BeautifulSoup(page.content,'lxml')
9
article= soup.findAll('p')
10
print(article)
11
i am getting many p tags within my code how to remove those tags ? here is my output
JavaScript
1
4
1
<p>The White House</p>, <p>THE PRESIDENT: My fellow Americans:
2
and Four years ago, we launched a.<p>, and to restore the allegiance this government to its citizens. In short, we embarked on a to make America all Americans.</p>, <p>As I conclude my term asthe 45th
3
of the United States, I — and so much more.</p>, <p>This week, and pray for its our best wishes, and we also want — a very important word.</p>
4
Advertisement
Answer
JavaScript
1
6
1
res=requests.get(r"https://trumpwhitehouse.archives.gov/briefings-statements/remarks-president-trump-farewell-address-nation/")
2
soup=BeautifulSoup(res.text,"html.parser")
3
data=soup.find("div",class_="page-content").find_all("p")
4
for d in data:
5
print(d.get_text())
6
Output:
JavaScript
1
4
1
The White House
2
THE PRESIDENT: My fellow Americans: Four years ago, we launched a great national effort to rebuild our country, to renew its spirit, and to restore the allegiance of this government to its citizens. In short, we embarked on a mission to make America great again — for all Americans.
3
.
4