Reputation: 912
I am using beautiful soup to collect data from HTML.
I need help to get the data inside 'class': 'Profile-userFullName-_EP'
Here is my trial to get the First Last name
from the current HTML.
import requests
from requests_html import HTMLSession
from bs4 import BeautifulSoup
url ='https://www.website.com'
r= requests.get(url)
soup = BeautifulSoup(r.text, 'html.parser')
name = soup.find_all('h1', {'class': 'Profile-userFullName-_EP'})
print(name)
My current output is:
[<h1 class="Profile-userFullName-_EP">First Last name</h1>]
My required output when I print name is:
First Last name
Upvotes: 0
Views: 293
Reputation: 287
soup.find_all()
returns an array, therefor name
is an array.
To get the innerHTML of the first element in the name
array you can do this:
innerHTML= name[0].decode_contents()
print(innerHTML)
Should print:
First Last name
Upvotes: 1