I'm receving a error when I want to convert a str to int in python
My code
from bs4 import BeautifulSoup as bs
import requests
link_cat = 'http://www.www.uol.com.br/'
r = requests.get(link)
soup = bs(r.content, "lxml")
for div in soup.find_all('a', {"class" : "last-page"}):
lp = div['href']
import re
regex = r"^.*\/([0-9]+)\/$"
#Define str
strlp = lp
matches = re.search(regex, strlp)
if matches:
for groupNum in range(0, len(matches.groups())):
groupNum = groupNum + 1
valor_final = matches.group(groupNum)
valor_final = int(matches.group(groupNum))
print(valor_final)
type(valor_final)
Traceback:
$ ypeError Traceback (most recent call last)
<ipython-input-167-498cbd1c956a> in <module>()
42
43 valor_final = matches.group(groupNum)
---> 44 valor_final = int(matches.group(groupNum))
45
46 print(valor_final)
TypeError: 'int' object is not callable