[Python] Python -> Get all valid media download url's from a webfolder

Discussão em 'Python' iniciado por Stack, Setembro 30, 2024.

  1. Stack

    Stack Membro Participativo

    I have a website here who has a link structure like this

    https://example.com/assets/contents/1627347928.mp4
    https://example.com/assets/contents/1627342345.mp4
    https://example.com/assets/contents/1627215324.mp4


    And I want to use python to get all links to download, when I access the folder /assets/contents/ i get a 404 error, so I can't see all the media to download from this web folder, but I know all the MP4 files has 10 CHARACTERS and all of them start with "1627******.mp4" Can I do a LOOP to check all the links from that website and get all VALID links?

    I could check if have media mp4/media with that code i can see the headers of a file, but how to make a loop to check all the links and download automatically? Or just show me the valid links?

    import requests
    link = 'https://example.com/assets/contents/1627347923.mp4'
    r = requests.get(link, stream=True)
    print(r.headers)

    Continue reading...

Compartilhe esta Página