How can I download a file that doesn’t actually have a download link?

I'm trying to use requests and BeautifulSoup to search for and download specific files, which I know how to do when the element's href link is "normal". However, for this project, the element's href is unusual (just a "#"), and doing a request.get() for any of the items within the <a> tag yields errors.

Here's the actual webpage itself

Here's an inspection of the page:

webpage/inspections screenshot

And here's a snippet of the code that's parsing it:

from bs4 import BeautifulSoup
import requests

url = ""
page = requests.get(url)
soup = BeautifulSoup(page.text, "html.parser")
a_list = list(enumerate(soup.find_all('a')))
for i, link in a_list:
    if ".ebc.gz" in link.get_text():
        response = requests.get(link["href"])
        test_file = open(f"{path}/test.ebc.gz", 'wb')

Clicking on the filename on the webpage yields the direct download I'm looking for.

Someone suggested here, to someone with a similar problem, that their download actually DID yield a link, but I can't figure out where or how this person saw that.

Read more here:

Content Attribution

This content was originally published by Travis Thompson at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: