I\'d like to do a very simple replacement using Beautiful Soup. Let\'s say I want to visit all A tags in a page and append \"?foo\" to their href. Can someone post or link to an
from BeautifulSoup import BeautifulSoup
soup = BeautifulSoup('''
Testing
foo
Bar
''')
for link in soup.findAll('a'): # find all links
link['href'] = link['href'] + '?foo'
print soup
That prints:
Testing
foo
Bar
The documentation also has some examples for changing attributes. It is an extensive tutorial that covers all common aspects of BeautifulSoup. I don't know what is missing from the documentation, maybe you should clarify.