Beautiful Soupを使用して抽出されたハイパーリンクの href 属性を使用して、単純な文字列操作を実行しようとしています。
from BeautifulSoup import BeautifulSoup
soup = BeautifulSoup('<a href="http://www.some-site.com/">Some Hyperlink</a>')
href = soup.find("a")["href"]
print href
print href[href.indexOf('/'):]
私が得るのは次のとおりです。
Traceback (most recent call last):
File "test.py", line 5, in <module>
print href[href.indexOf('/'):]
AttributeError: 'unicode' object has no attribute 'indexOf'
何でもhref
通常の文字列に変換するにはどうすればよいですか?