Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

how to find pdf file in link beautifulsoup

# Find links to pdf files in HTML with BeautifulSoup

import urllib2
from bs4 import BeautifulSoup
my_url = 'http://slav0nic.org.ua/static/books/python/'
html=urllib2.urlopen(my_url).read()
sopa = BeautifulSoup(html)
current_link = ''
for link in sopa.find_all('a'):
  current_link = link.get('href')
    if current_link.endswith('pdf'):
      print('Tengo un pdf: ' + current_link)
Source by gist.github.com #
 
PREVIOUS NEXT
Tagged: #find #pdf #file #link #beautifulsoup
ADD COMMENT
Topic
Name
4+8 =