Si l'attribut href suivent un modèle littéral comme href = « ... regarder ... » Vous pouvez facilement résoudre le problème en utilisant re: expression régulière.
import re
from bs4 import BeautifulSoup
response = """<a href="/watch?gl=US&client=mv-google&hl=en&v=0C_yXOhJxWg">Miss Black OCU 2011</a>"""
# the response should might be the urlreponse object if you search through a whole html page
soup = BeautifulSoup(response)
print soup.find("a", {"href":re.compile(".*watch.*")}).text
La sortie est comme ceci:
Miss Black OCU 2011
Le tout est de trouver le modèle d'expression régulière. Plus d'infos sur re, cliquez ici http://docs.python.org/2/library/re.html: