'Python Error - 'str' object is not callable

I am a week into learning Python following 'Automate the Boring Stuff with Python' and am trying to run this web scraper program but am receiving the following error:

Traceback (most recent call last):
  File "F:/PythonProjects/webscaperprice.py", line 13, in <module>
    price = getEbayPrice('http://www.ebay.com/itm/401911857365?epid=1274633325&hash=item5d93d040d5:g:Ox8AAOSwERFdmKB4')
  File "F:/PythonProjects/webscaperprice.py", line 9, in getEbayPrice
    return elems[0].text()
TypeError: 'str' object is not callable
import bs4, requests

def getEbayPrice(productURL):
    res = requests.get(productURL)
    res.raise_for_status()

    soup = bs4.BeautifulSoup(res.text, 'html.parser')
    elems = soup.select('#prcIsum')
    return elems[0].text()

price = getEbayPrice('https://www.ebay.com/itm/401911857365?epid=1274633325&hash=item5d93d040d5:g:Ox8AAOSwERFdmKB4')  
print('The price is ' + price)


Solution 1:[1]

You simply need return elems[0].text, as "text" here points to a string directly and not a method to get the text.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Guimoute