Issue
<div class="product-name">
CLR2811
</div>
I want to scrape this Product name. My Code :
ProductTitle = page_soup.find("div",attrs = {'class':'product-name'})
This Should Probably return me the right things i-e CLR2811 but when I print ProductTitle its returns me.
<div class="product-name">
</div>
Just the name is missing URL = http://www.coolline-group.com/product-details.php?pid=5a3c8ac755d2f
Solution
As @AlexDotis pointed you, you need to use the element's text attribute:
from bs4 import BeautifulSoup
import requests
headers = requests.utils.default_headers()
headers.update({ 'User-Agent': 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0'})
url = "http://www.coolline-group.com/product-details.php?pid=5a3c8ac755d2f"
req = requests.get(url, headers)
soup = BeautifulSoup(req.content, 'html.parser')
name = soup.find("div",attrs = {'class':'product-name'})
print (name.text.strip())
Output:
CLR2811
Answered By - Maurice Meyer
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.