Comments (3)
As far as I know, Python open()
can handle both format, unless it breaks somewhere else. I am running under Windows 10 too and it works just fine. It might break if you changed the code by adding other libraries on your own which cannot handle the forward-slash path.
What was the error?
Can you try changing create_path()
to the following to see if it works out fine:
def create_path(path):
path = os.path.join('', path)
if not os.path.exists(path):
os.makedirs(path)
return path
from springer_free_books.
The error is (for each book that needs the 'tmp'):
[WinError 123] El nombre de archivo, el nombre de directorio o la sintaxis de la etiqueta del volumen no son correctos: '.\tmp' that in english seems to translate as "The filename, directory name, or volume label syntax is incorrect" that is a bit generic error.
Unfortunatelly I made a mistake with the first workaround and I finished with subdirs with the name of the books with the book inside with name "-temp_file-.bak". Due I supposed book_path was only the book path without including the book name.
With this _download_book tunned function I have downloaded all the books in my Win 10 Spanish (but I have not tested it in other OS's:
def _download_book(url, book_path):
if not os.path.exists(book_path):
with requests.get(url, stream=True) as req:
# path = create_path('.\tmp')
tmp_folder = os.path.join(os.path.split(book_path)[0], 'tmp')
path = create_path(tmp_folder)
tmp_file = os.path.join(path, '_-_temp_file_-_.bak')
with open(tmp_file, 'wb') as out_file:
shutil.copyfileobj(req.raw, out_file)
out_file.close()
shutil.move(tmp_file, book_path)
shutil.rmtree(tmp_folder)
I have used the os.path functions join and split to create a tmp folder inside each book genre and I removed it (each time a book is downloaded... I know is not very optimized) with rmtree from shutil
from springer_free_books.
As far as I know, Python
open()
can handle both format, unless it breaks somewhere else. I am running under Windows 10 too and it works just fine. It might break if you changed the code by adding other libraries on your own which cannot handle the forward-slash path.What was the error?
Can you try changing
create_path()
to the following to see if it works out fine:def create_path(path): path = os.path.join('', path) if not os.path.exists(path): os.makedirs(path) return path
I forget to comment that I tried firstly your tunned function create_path but I have found the same "[WinError 123] " than with the original one.
from springer_free_books.
Related Issues (20)
- object of type 'float' has no len() HOT 1
- Problem with run_VirtualEnv.bat HOT 1
- Duplicate downloading the pdf files as epub
- Possible Introduction of reCaptcha by Springer? HOT 1
- Error: probably not a valid book HOT 7
- Please share the archive HOT 2
- Somebody please mirror and make a torrent HOT 3
- [Feature Request] Springer's 1000 open-access books HOT 2
- Link to the downloaded books HOT 3
- Use specific User-Agent to bypass Google captcha HOT 1
- in windows : import pandas report error ImportError: DLL load failed while importing aggregations:找不到指定模块
- Download fails around 4%, "File name too long" & NameError: name 'time' is not defined HOT 8
- excel file indices missing - can't download specific books HOT 8
- AttributeError: 'Int64Index' object has no attribute 'array' HOT 4
- HTTP Error 404: Not Found HOT 4
- Where are the downloaded files? HOT 2
- HTTP Error 404 Not Found but I was able to manually download spreadsheet HOT 4
- I just found all the download links HOT 15
- KeyError: 'content-length' HOT 8
- Problem with Docker/Raspberry Pi
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from springer_free_books.