@juanito wrote:
For example, this url
http://www.elsevier.es/en-revista-international-journal-clinical-health-psychology-355-numeros-anteriores
You take links from years and put into anos.txt (csv style)
2013;http://www.elsevier.es/en-revista-international-journal-clinical-health-psychology-355-numeros-anteriores-anio-2013 2014;http://www.elsevier.es/en-revista-international-journal-clinical-health-psychology-355-numeros-anteriores-anio-2014 2015;http://www.elsevier.es/en-revista-international-journal-clinical-health-psychology-355-numeros-anteriores-anio-2015
Then you create, elsemier.sh with this content
#!/bin/bash URL="http://www.elsevier.es" ANOS=anos.txt IFS=";" # Recorrer cada año while read ano anourl do # Sacar enlace de cada revista, según año echo "ano : $ano" echo "anourl : $anourl" echo "Entrando en $ano para sacar las revistas" curl -s $anourl | pup '.enlace_grande attr{href}' > revistas.txt # Dentro de cada revista while read revistaurl do if [ "$revistaurl" != "http://www.publicationethics.org" ]; then #echo $revistaurl vol="$(echo $revistaurl | cut -d'-' -f11)" num="$(echo $revistaurl | cut -d'-' -f13)" echo "Volumen $vol-$num Número" # Bajar revista echo "Entrando en la revista $revistaurl" # Sacando los enlaces de los artículos de cada revista curl -s "$URL$revistaurl" | pup '.enlace attr{href}' > enlacesarticulos.txt echo $URL$revistaurl # recorrer artículos x=1 while read urlpdf do if [ ! -f $ano-$vol-$num-$x.pdf ]; then if [[ $urlpdf = *"pdf"* ]]; then echo "El enlace baja directamente el PDF" #El título del artículo es el enlace al pdf echo "Bajando $ano-$vol-$num-$x.pdf" wget "$URL$urlpdf" -O $ano-$vol-$num-$x.pdf --user-agent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:21.0) Gecko/20100101 Firefox/47.0" else echo "Entrar dentro del artículo para sacar el enlace del PDF" #El título del artículo es enlace al artículo, el pdf está dentro urlpdefe=$(curl -s "$URL$urlpdf" | pup '.listaHerramientas .pdf .enlace_negro attr{href}') echo $URL$urlpdefe echo "Bajando $ano-$vol-$num-$x.pdf" wget "$URL$urlpdefe" -O $ano-$vol-$num-$x.pdf --user-agent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:21.0) Gecko/20100101 Firefox/47.0" fi fi ((x++)) echo "dormir" sleep 2 done < enlacesarticulos.txt fi done < revistas.txt done < $ANOS
You need pup
wget https://github.com/ericchiang/pup/releases/download/v0.4.0/pup_v0.4.0_linux_amd64.zip unzip pup_v0.4.0_linux_amd64.zip sudo cp pup /usr/local/bin
Then, you can execute it
bash elsemier.sh
If you need help, whistle me. Thanks for OJS
Posts: 1
Participants: 1