mercredi 6 mai 2015

Beautiful Soup Find - get just the text

I had this bit of code spitting out just the price as a string (125.01), but I must have changed something because now it prints the whole line with the html tags and everything. How can i get it to print out just the text, without using regular expressions?

import requests
from bs4 import BeautifulSoup

url = 'http://ift.tt/1IiBh0j'

data = requests.get(url)
soup = BeautifulSoup(data.content)
price = soup.find("span", {'id':'yfs_l84_aapl'})
print(price)


<span id="yfs_l84_aapl">125.01</span>




Aucun commentaire:

Enregistrer un commentaire