0

I'm trying to fetch a file from a website which is a .edf file. When I click on it, it opens the corresponding text view in the browser. But if I save the content as to a directory everything works fine.

And the question is since I have a lot of file like this I wanted to use python to fetch all of them automatically and save in a directory. So, how can I use beautifulsoup or selenium or any library to get this file in a directory just like using "saving as" option?

note: Reading the file with using soup.read() and trying to write on a .edf file is not working.

import urllib2
from bs4 import BeautifulSoup
res=urllib2.urlopen('https://www.physionet.org/pn4/eegmmidb/S001/S001R03.edf')    

html = response.read()
soup = BeautifulSoup(html,'html.parser')

testfile = open('tfile.edf','w')
testfile.write(soup.encode('utf-8'))
testfile.close()

It's working but the data is not contains in .edf file as reading the html content.

There is a image file in below which may explain my purpose.

Basically and shortly what I'm trying to do is saving the file content in a specific directory with using python.

image file

3
  • Your question is not specific enough, explain what you have tried with an example if possible and explanation of which part is not providing the expected results. Please read the SO guidelines before posting. Commented Jan 8, 2018 at 0:11
  • ok! How about now? It's really hard to explain such a thing. I'm struggling with the words to explain to this case. Commented Jan 8, 2018 at 0:35
  • This looks much better. Someone with more domain knowledge should be able to answer this question now. Commented Jan 8, 2018 at 0:39

1 Answer 1

2

I figure out how to do it. If anyone wants to learn here is the answer.

import urllib    
urllib.urlretrieve('link','file to be save')

you can easly save the file with this code!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.