Reputation: 10755
I have working with Python and I have some questions:
Here is code example:
html = BeautifulSoup(p)
x = html.find('a', attrs={'href':'/slideshow'})
while x:
print 'x unchanged - ', x
x=x.replaceWith('<a href="/slideshow_v2">')
print 'x changed - ', x
Thanks for help !!!
Upvotes: 0
Views: 197
Reputation: 6782
here is a solution to your problem:
html = BeautifulSoup(p)
anchors = html.findAll('a', href='/slideshow')
for anchor in anchors:
anchor['href'] = '/slideshow_v2'
print html.findAll('a', href='/slideshow_v2')
Take into acount please that this is not a Django related question.
Good luck!
Upvotes: 1