Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests
- from bs4 import BeautifulSoup
- def gotovaSlika(url = 'http://s2s.fonis.rs/img/Agenda.jpg'):
- naziv = url.split('/')[-1]
- url=url.replace('/./', '/')
- url = url.replace('.rs//', '.rs/')
- print("skida se slika sa url-a: ", url)
- r = requests.get(url, allow_redirects=True)
- # fajl = open(naziv, 'wb')
- #
- # fajl.write(r.content)
- try:
- open(naziv, 'wb').write(r.content)
- except:
- print("Nije doslo do greske, sve kul casna rec")
- def nadjiSlike(url = 'http://s2s.fonis.rs'):
- url = url.replace('/./', '/')
- url = url.replace('.rs//', '.rs/')
- print('\n\nObradjuje se sajt:', url, "\n\n")
- sors = requests.get(url)
- tekst = sors.text
- supa = BeautifulSoup(tekst, features="html.parser")
- for link in supa.findAll('a'):
- url_privremeni = url + '/' + link.get('href').strip('.')
- print(url_privremeni)
- if url_privremeni.endswith('html'):
- print("Ulazimo u sajt: ", url_privremeni)
- nadjiSlike(url_privremeni)
- if url_privremeni.endswith('jpg') or url_privremeni.endswith('png') or url_privremeni.endswith('pdf'):
- gotovaSlika(url_privremeni)
- for link in supa.findAll('img'):
- url_privremeni = 'http://s2s.fonis.rs' + '/' + link.get('src')
- gotovaSlika(url_privremeni)
- #nadjiSlike()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement