How to find links and modify an Html using BeautifulSoup in Python
- by systempuntoout
Starting from an Html input like this:
<p>
<a href="http://www.foo.com">this if foo</a>
<a href="http://www.bar.com">this if bar</a>
</p>
using BeautifulSoup, i would like to change this Html in:
<p>
<a href="http://www.foo.com">this if foo[1]</a>
<a href="http://www.bar.com">this if bar[2]</a>
</p>
saving parsed links in a dictionary with a result like this:
links_dict = {"1":"http://www.foo.com","2":"http://www.bar.com"}
Is it possible to do this using BeautifulSoup? Any valid alternative?