what is the return value of BeautifulSoup.find ?
Posted
by prosseek
on Stack Overflow
See other posts from Stack Overflow
or by prosseek
Published on 2010-04-15T17:09:35Z
Indexed on
2010/04/15
17:13 UTC
Read the original article
Hit count: 265
beautifulsoup
|regex
I run to get some value as score.
score = soup.find('div', attrs={'class' : 'summarycount'})
I run 'print score' to get as follows.
<div class=\"summarycount\">524</div>
I need to extract the number part. I used re module but failed.
m = re.search("[^\d]+(\d+)", score)
TypeError: expected string or buffer function search in re.py at line 142 return _compile(pattern, flags).search(string)
- What's the return type of the find function?
- How to get the number from the score variable?
- Is there any easy way to let BeautifulSoup to return the value(in this case 524) itself?
© Stack Overflow or respective owner