list files in http directory python

Solutions on MaxInterview for list files in http directory python by the best coders in the world

showing results for - "list files in http directory python"
Victoria
17 Sep 2016
1import requests
2from bs4 import BeautifulSoup
3
4def get_url_paths(url, ext='', params={}):
5    response = requests.get(url, params=params)
6    if response.ok:
7        response_text = response.text
8    else:
9        return response.raise_for_status()
10    soup = BeautifulSoup(response_text, 'html.parser')
11    parent = [url + node.get('href') for node in soup.find_all('a') if node.get('href').endswith(ext)]
12    return parent
13
14url = 'http://cdimage.debian.org/debian-cd/8.2.0-live/i386/iso-hybrid'
15ext = 'iso'
16result = get_url_paths(url, ext)
17print(result)
18