Reading files from web

Back to Programming Languages forum

pyth_mastr     2014-10-19 17:48:17

I'm using python and I wish to read a file from the website(as in the anagram puzzle ) Is it possible to do so using the in browser environment ? I tried using: fh =open('words.txt','r') or fh =open('./data/words.txt','r') with no success . Any ideas ?

Rodion (admin)     2014-10-19 18:42:26
User avatar

Hi!

I'm afraid that solutions for problems which require external data files currently could not be executed with "on-site run" feature (because they are run on different server at all). :(

So the most straightforward way is to use Python interpreter on your local machine and download files here (i.e. click the link with right button and choose "save as"). (you also can load files in your local python directly from site by using urllib2 for example) and specifying their full address.

There are some more kinds of problems which are unsuitable for running on-site - either because they need long execution time, or external resources like files or even web-pages (e.g. "Social Net Scraper").

nicolas_patrois     2014-10-21 13:13:57
User avatar

Like this:

from sys import stdin

for line in stdin:
     print(line)
Please login and solve 5 problems to be able to post at forum