Fórum Ubuntu CZ/SK

Ubuntu pro osobní počítače => Internet a sítě => Téma založeno: Martin Šácha 25 Února 2012, 15:39:06

Název: Wget a URL s UTF-8 [bug, workaround posted]
Přispěvatel: Martin Šácha 25 Února 2012, 15:39:06
Ahoj, potřebuji postahovat všechny linky z html souboru se *zachováním stromové struktury těch linků, problém je že jsou v URL mezery, diakritika a další podivný znaky. Spojení se naváže, soubor najde, ale nestáhne...

je to španělský systém tak se moc nedivte:)
Kód: [Vybrat]
--2012-02-25 15:02:20--  http://www.example.com/uploader/files/carlos/skola/fjfi/angli%C4%8Dtina/ap%20-%20%C4%8D%C3%A1pov%C3%A1/ukol%20-%20cover%20letter.docx
Conectando a www.example.com|192.168.0.88|:80... conectado.
Petición HTTP enviada, esperando respuesta... 200 OK
Longitud: 13200 (13K) [application/vnd.openxmlformats-officedocument.wordprocessingml.document]
www.example.com/uploader/files/carlos/skola/fjfi/angli�%8Dtina/ap - �%8Dápová: No existe el fichero o el directorio
www.example.com/uploader/files/carlos/skola/fjfi/angli�%8Dtina/ap - �%8Dápová/ukol - cover letter.docx: No existe el fichero o el directorio

No se puede escribir en «www.example.com/uploader/files/carlos/skola/fjfi/angli\304%8Dtina/ap - \304%8Dápová/ukol - cover letter.docx» (No existe el fichero o el directorio).

Zkoušel jsem a výstup stejný:(
Kód: [Vybrat]
~$ wget --input-file="/dev/shm/upl.txt" --force-html --force-directories --header="Accept-Encoding: utf-8"
~$ wget --input-file="/dev/shm/upl.txt" --force-html --force-directories --restrict-file-names="nocontrol"
~$ wget --input-file="/dev/shm/upl.txt" --force-html --force-directories --remote-encoding="UTF-8"
 Esta version no permite IRI

Díky za nakopnutí...
Název: Re:Wget a URL s UTF-8
Přispěvatel: jmp 25 Února 2012, 15:43:44
Citace
No existe el fichero o el directorio
neznamena to nahodou, ze soubor nebo adresar neexistuje?
Název: Re:Wget a URL s UTF-8
Přispěvatel: Martin Šácha 25 Února 2012, 15:45:34
Ano, ale tam je jasne videt ze si z textaku ten link vezme, pripoji se na server, dostane 200 OK, a az pak ho neulozi.
Název: Re:Wget a URL s UTF-8
Přispěvatel: Krysař 25 Února 2012, 18:04:50
A poradi si spanelsky system s diakritikou? Mozna by pomohlo: (man wget)
Kód: [Vybrat]
--restrict-file-names=modes
           Change which characters found in remote URLs must be escaped
           during generation of local filenames.  Characters that are
           restricted by this option are escaped, i.e. replaced with %HH,
           where HH is the hexadecimal number that corresponds to the
           restricted character. This option may also be used to force all
           alphabetical cases to be either lower- or uppercase.
...
...
           If you specify nocontrol, then the escaping of the control
           characters is also switched off. This option may make sense when
           you are downloading URLs whose names contain UTF-8 characters, on
           a system which can save and display filenames in UTF-8 (some
           possible byte values used in UTF-8 byte sequences fall in the
           range of values designated by Wget as "controls").

           The ascii mode is used to specify that any bytes whose values are
           outside the range of ASCII characters (that is, greater than 127)
           shall be escaped. This can be useful when saving filenames whose
           encoding does not match the one used locally.
Název: Re:Wget a URL s UTF-8
Přispěvatel: Martin Šácha 25 Února 2012, 19:48:53
--restrict-file-names=nocontrol/unix/ascii jsem zkoušel a nic:( A přitom ze serveru odpověd přijde, soubor existuje, pošle jeho velikost a mime-type...viz výpis nahoře.
Název: Re:Wget a URL s UTF-8
Přispěvatel: Martin Šácha 25 Února 2012, 20:09:46
Problém byl mezi NTFS, truecryptem a wokenim kodovanim nazvů souborů. Nicméně stačí někde v unixovém prostoru udělat simlink a už to funguje jak má :)

Howto fix:
Kód: [Vybrat]
~$ mkdir /cesta/k/cilovemu/adresari
~$ cd /dev/shm
~$ ln -s /cesta/k/cilovemu/adresari
~$ cd ./<nazev_adresare>
~$ wget [volby] --restrict-file-names=ascii