Issue
I am scraping with Python
using BeautifulSoap
I have to scrape the text inside DIV
<div class="map-address">
O'Riordan Street,
Mascot 2020 NSW Australia,
(Corner Robey Street)
</div>
I have this code
print (soup.select('div.map-address'))
But I get this output
[<div class="map-address">
O'Riordan Street,
Mascot 2020 NSW Australia,
(Corner Robey Street)
</div>]
I have also tried
print (soup.select('div.map-address').text)
# Error ... no attribute named text
Solution
I solved it:
if not soup.select('div.map-address'):
print ("No Address")
else:
print (hotel_page_soup.select('div.map-address')[0].text)
Answered By - Umair Ayub
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.