Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Multiple File Downloader
#1
I'm trying to create a program which downloads multiple files from the url below. To download each file you have to click on the link of the game, then click on the 'download' link near the bottom of the game. I'd then have to go back onto the main page and repeat. The main problem I have is that I have no idea how to save the files to a specific direcotry. Below is the small amount I've pieced together from other forums.


from urllib.request import urlopen, urlretrieve, quote
from bs4 import BeautifulSoup

url = 'http://www.chessgames.com/perl/chesscollection?cid=1014492'
u = urlopen(url)
try:
    html = u.read().decode('utf-8')
finally:
    u.close()

soup = BeautifulSoup(html)
for link in soup.select('br a'):
    href = link.get('href')
    file_name = link.get_text()
    urlretrieve(href, file_name)
Reply
#2
see https://python-forum.io/Thread-Web-Scraping-part-1
and https://python-forum.io/Thread-Web-scraping-part-2
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  m3u8 using build-in browser downloader? kucingkembar 3 305 Mar-29-2024, 01:47 AM
Last Post: kucingkembar
  Can not make this image downloader work Blue Dog 6 4,086 Jun-23-2020, 08:55 PM
Last Post: snippsat
  RFC downloader not working sidsr003 2 2,761 Dec-19-2018, 09:31 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020