Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import bs4
- import requests
- s = requests.session()
- base_url = r'http://www.imagebam.com'
- limb_url = r'/image/c6b0cf70777810/'
- image_links = []
- done = False
- next_found = False
- while not done:
- url = base_url + limb_url
- r = s.get(url)
- soup = bs4.BeautifulSoup(r.content)
- link_elems = soup.findAll(attrs={'class': 'buttonblue'})
- for link in link_elems:
- if 'save' in link.text:
- image_links.append(link['href'])
- print 'saving this link:', link['href']
- elif 'next' in link.text:
- limb_url = link['href']
- print 'found', limb_url
- next_found = True
- if not next_found:
- print 'else, so were done for this page'
- done = True
- print image_links
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement