1# Find links to pdf files in HTML with BeautifulSoup
2
3import urllib2
4from bs4 import BeautifulSoup
5my_url = 'http://slav0nic.org.ua/static/books/python/'
6html=urllib2.urlopen(my_url).read()
7sopa = BeautifulSoup(html)
8current_link = ''
9for link in sopa.find_all('a'):
10 current_link = link.get('href')
11 if current_link.endswith('pdf'):
12 print('Tengo un pdf: ' + current_link)