קוד: |
#!/bin/bash cat books_list.csv | while read line; do IFS=',' read -a array <<< "$line" FILE_NAME=${array[0]} TOPIC=${array[1]} URL=${array[2]} echo Download $FILE_NAME #find the real url REAL_URL=`curl $URL -s -L -I -o /dev/null -w '%{url_effective}'` BOOK_ID=`echo ${REAL_URL##*/}` DOWNLOAD_URL='https://link.springer.com/content/pdf/'${BOOK_ID}.pdf curl $DOWNLOAD_URL --create-dirs -o "${TOPIC}"/"${FILE_NAME}".pdf done |
קוד: |
./filename |
קוד: |
#!/bin/bash topics=("Physics and Astronomy" "Mathematics and Statistics" "Computer Science") cat books_list.csv | while read line; do IFS=',' read -a array <<< "$line" FILE_NAME=${array[0]} TOPIC=${array[1]} URL=${array[2]} if [[ " ${topics[@]} " =~ " ${TOPIC} " ]] then echo Download $FILE_NAME #find the real url REAL_URL=`curl $URL -s -L -I -o /dev/null -w '%{url_effective}'` BOOK_ID=`echo ${REAL_URL##*/}` DOWNLOAD_URL='https://link.springer.com/content/pdf/'${BOOK_ID}.pdf curl $DOWNLOAD_URL --create-dirs -o "${TOPIC}"/"${FILE_NAME}".pdf fi done |
קוד: |
import csv import os CATEGORIES = ('Computer Science', 'Business and Economics', 'Business and Management', 'Mathematics and Statistics', 'Engineering') with open("./data.csv", "r") as fp: reader = csv.reader(fp) for row in reader: if row[0] == "Book Title": continue category = row[11] if not category in CATEGORIES: continue id = row[17].replace("http://doi.org/", "") link = f"https://link.springer.com/content/pdf/{id}.pdf" fn = f"{category}/{row[0]} - {row[1]} ({row[4]}).pdf" cmd=f"curl -SL --create-dirs -o '{fn}' '{link}'" os.system(cmd) |
Anonymous : | ||
עוד סקרפיט למי שרוצה בשימוש ב csv המקורי מ google docs ללא שינוי.
|
Anonymous : | ||
https://pastebin.com/zxzwxbiX
הרשימה מכאן, תורידו הכל עם הסקריפט
|
קוד: |
curl: (3) URL using bad/illegal format or missing URL ./4.txt: line 28: $'\r': command not found ./4.txt: line 5: $'\r': command not found ./4.txt: line 6: $'\r': command not found ./4.txt: line 8: $'\r': command not found ./4.txt: line 10: $'\r': command not found ./4.txt: line 12: $'\r': command not found ./4.txt: line 14: $'\r': command not found Download "Clinical Methods in Medical Family Therapy ./4.txt: line 16: $'\r': command not found ./4.txt: line 17: $'\r': command not found ./4.txt: line 18: $'\r': command not found ./4.txt: line 20: $'\r': command not found |
קוד: |
#!/bin/bash
topics=("Physics and Astronomy" "Mathematics and Statistics" "Computer Science") cat data.csv | while read line; do IFS=',' read -a array <<< "$line" FILE_NAME=${array[0]} TOPIC=${array[1]} URL=${array[2]} if [[ " ${topics[@]} " =~ " ${TOPIC} " ]] then echo Download $FILE_NAME #find the real url REAL_URL=`curl $URL -s -L -I -o /dev/null -w '${URL}'` BOOK_ID=`echo ${REAL_URL##*/}` DOWNLOAD_URL='https://link.springer.com/content/pdf/'${BOOK_ID}.pdf curl $DOWNLOAD_URL --create-dirs -o "${TOPIC}"/"${FILE_NAME}".pdf fi done |
Anonymous : | ||
הייתה שגיאה בקוד !
זה הקוד המתוקן :
|
קוד: |
./4.txt: line 2: $'\r': command not found
./4.txt: line 4: $'\r': command not found ./4.txt: line 17: syntax error in conditional expression '/4.txt: line 17: syntax error near `]] '/4.txt: line 17: ` if [[ " ${topics[@]} " =~ " ${TOPIC} " ]] |
קוד: |
$ ./springer_python.py
./springer_python.py: line 8: syntax error near unexpected token `(' ./springer_python.py: line 8: `CATEGORIES = ("Computer Science",' |
קוד: |
$ ./springer_python.py
./springer_python.py: line 8: syntax error near unexpected token `(' ./springer_python.py: line 8: `CATEGORIES = ('Computer Science',' |
קוד: |
s = open(r'source.txt', 'r')
d = '' m = open(r'result.txt', 'w') for row in s: q = row.split('isbn=') w = q[1] r = "%2F" d = 'https://link.springer.com/content/pdf/10.1007{}{}.pdf\n'.format(r, w) m.write(d) |
ציטוט: |
לאלו שהיו בעיות עם הסקריפט BASH - רוב הסיכויים שלא שמרתם נכון את הקובץ CSV - הורידו RAW מ PASTEBIN - והשתמשו בקובץ CSV המתוקן כי בקובץ המקורי יש פסיקים בשמות בספרים וזה דופק את ההורדות שלהם. |
Anonymous : | ||
הייתה שגיאה בקוד !
זה הקוד המתוקן :
|
ציטוט: |
These links no longer work. Springer have pulled the free plug. |