Найти конкретные комментарии в HTML-коде, используя Python
Я не могу найти конкретный комментарий в Python, например,<!-- why -->
.
My main reason is to find all the links inside 2 specific comments. Something like a parser.
I tried this with Beautifulsoup
:
import urllib
over=urlopen("www.gamespot.com").read()
soup = BeautifulSoup(over)
print soup.find("<!--why-->")
Но это не работает.
Я думаю, что, возможно, придется использоватьregex
и неBeautifulsoup
.
Пожалуйста помоги.
ПРИМЕР: у нас есть HTML-код, как это
<!--why-->
www.godaddy.com
<p> nice one</p>
www.wwf.com
<!-- why not-->
EDIT: Between the 2 comments, other stuff, like tags, might exist.
И мне нужно хранить все ссылки.