[Linux-bruxelles] problème avec wget -m et faire une copie pour consultation offline d'un site web

Depuydt, Patrick patrick at htag2.com
Lun 4 Mar 10:16:32 CET 2019


Bon les mecs,

Un peu de bon sens, réfléchissons ensemble:
1) wget ce n'est pas un client web.
2) Les sites peuvent savoir quel programme se connecte à un serveur web
(c'est ce qu'on appelle le USER_AGENT)
3) Il y a moyen de "faker" ce USER_AGENT
4) La pluspart des blocages de bots se fait justement grâce à ce user agent

Alors comment qu'on fait ?

voici la formule magique (je vous renvoie au 'man wget' pour plus d'infos):

#~: wget -r -m --header="User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:23.0)
Gecko/20100101 Firefox/23.0" https://www.tabs4acoustic.com

Resultat:

[myuser at localhost ~]$ wget -m -r https://www.tabs4acoustic.com
--header="User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:23.0) Gecko/20100101
Firefox/23.0"
--2019-03-04 10:01:02--  https://www.tabs4acoustic.com/
Resolving ****proxy_address**** (****proxy_address****)... XXX.XXX.XXX.XXX
Connecting to ****proxy_address****
(****proxy_address****)|XXX.XXX.XXX.XXX|:xxxx... connected.
Proxy request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Last-modified header missing -- time-stamps turned off.
--2019-03-04 10:01:03--  https://www.tabs4acoustic.com/
Connecting to ****proxy_address****
(****proxy_address****)|XXX.XXX.XXX.XXX|:xxxx... connected.
Proxy request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: ‘www.tabs4acoustic.com/index.html’

    [
<=>
] 45,854      --.-K/s   in 0.01s

2019-03-04 10:01:03 (2.92 MB/s) - ‘www.tabs4acoustic.com/index.html’ saved
[45854]

Loading robots.txt; please ignore errors.
--2019-03-04 10:01:03--  https://www.tabs4acoustic.com/robots.txt
Connecting to ****proxy_address****
(****proxy_address****)|XXX.XXX.XXX.XXX|:xxxx... connected.
Proxy request sent, awaiting response... 200 OK
Length: 154 [text/plain]
Saving to: ‘www.tabs4acoustic.com/robots.txt’

100%[===========================================================================>]
154         --.-K/s   in 0s

2019-03-04 10:01:03 (17.4 MB/s) - ‘www.tabs4acoustic.com/robots.txt’ saved
[154/154]

--2019-03-04 10:01:03--  https://www.tabs4acoustic.com/images/favicon.ico
Connecting to ****proxy_address****
(****proxy_address****)|XXX.XXX.XXX.XXX|:xxxx... connected.
Proxy request sent, awaiting response... 200 OK
Length: 1150 (1.1K) [image/x-icon]
Saving to: ‘www.tabs4acoustic.com/images/favicon.ico’

100%[===========================================================================>]
1,150       --.-K/s   in 0s

2019-03-04 10:01:03 (131 MB/s) - ‘www.tabs4acoustic.com/images/favicon.ico’
saved [1150/1150]

--2019-03-04 10:01:03--
https://www.tabs4acoustic.com/min/?b=css&f=main.css,foundation.min.css,menu.css,resp.css,smartbanner.css
Connecting to ****proxy_address****
(****proxy_address****)|XXX.XXX.XXX.XXX|:xxxx... connected.
Proxy request sent, awaiting response... 200 OK
Length: 125749 (123K) [text/css]
Saving to: ‘
www.tabs4acoustic.com/min/index.html?b=css&f=main.css,foundation.min.css,menu.css,resp.css,smartbanner.css
’

100%[===========================================================================>]
125,749     --.-K/s   in 0.03s

2019-03-04 10:01:03 (3.78 MB/s) - ‘
www.tabs4acoustic.com/min/index.html?b=css&f=main.css,foundation.min.css,menu.css,resp.css,smartbanner.css’
saved [125749/125749]

--2019-03-04 10:01:03--  https://www.tabs4acoustic.com/rss/fr/t4a.xml
Connecting to ****proxy_address****
(****proxy_address****)|XXX.XXX.XXX.XXX|:xxxx... connected.
Proxy request sent, awaiting response... 200 OK
Length: 17031 (17K) [application/xml]
Saving to: ‘www.tabs4acoustic.com/rss/fr/t4a.xml’

100%[===========================================================================>]
17,031      --.-K/s   in 0s

2019-03-04 10:01:03 (155 MB/s) - ‘www.tabs4acoustic.com/rss/fr/t4a.xml’
saved [17031/17031]

--2019-03-04 10:01:03--  https://www.tabs4acoustic.com/rss/fr/forums.xml
Connecting to ****proxy_address****
(****proxy_address****)|XXX.XXX.XXX.XXX|:xxxx... connected.
Proxy request sent, awaiting response... 200 OK
Length: 244 [application/xml]
Saving to: ‘www.tabs4acoustic.com/rss/fr/forums.xml’

100%[===========================================================================>]
244         --.-K/s   in 0s

2019-03-04 10:01:03 (26.2 MB/s) - ‘www.tabs4acoustic.com/rss/fr/forums.xml’
saved [244/244]

--2019-03-04 10:01:03--  https://www.tabs4acoustic.com/flux-rss.html
Connecting to ****proxy_address****
(****proxy_address****)|XXX.XXX.XXX.XXX|:xxxx... connected.
Proxy request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: ‘www.tabs4acoustic.com/flux-rss.html’

    [
<=>
] 31,548      --.-K/s   in 0.003s

Last-modified header missing -- time-stamps turned off.
2019-03-04 10:01:04 (9.56 MB/s) - ‘www.tabs4acoustic.com/flux-rss.html’
saved [31548]

--2019-03-04 10:01:04--
https://www.tabs4acoustic.com/images/design/t4a_img.gif
Connecting to ****proxy_address****
(****proxy_address****)|XXX.XXX.XXX.XXX|:xxxx... connected.
Proxy request sent, awaiting response... 200 OK
Length: 43 [image/gif]
Saving to: ‘www.tabs4acoustic.com/images/design/t4a_img.gif’

100%[===========================================================================>]
43          --.-K/s   in 0s

2019-03-04 10:01:04 (4.74 MB/s) - ‘
www.tabs4acoustic.com/images/design/t4a_img.gif’ saved [43/43]

--2019-03-04 10:01:04--
https://www.tabs4acoustic.com/images/android_accordeur_guitare.png
Connecting to ****proxy_address****
(****proxy_address****)|XXX.XXX.XXX.XXX|:xxxx... connected.
Proxy request sent, awaiting response... 200 OK
Length: 13490 (13K) [image/png]
Saving to: ‘www.tabs4acoustic.com/images/android_accordeur_guitare.png’

100%[===========================================================================>]
13,490      --.-K/s   in 0s

2019-03-04 10:01:04 (212 MB/s) - ‘
www.tabs4acoustic.com/images/android_accordeur_guitare.png’ saved
[13490/13490]

--2019-03-04 10:01:04--  https://www.tabs4acoustic.com/recherche-t4a.html
Connecting to ****proxy_address****
(****proxy_address****)|XXX.XXX.XXX.XXX|:xxxx... connected.
Proxy request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: ‘www.tabs4acoustic.com/recherche-t4a.html’

    [
<=>
] 91,363      --.-K/s   in 0.02s

Last-modified header missing -- time-stamps turned off.
2019-03-04 10:01:04 (3.74 MB/s) - ‘www.tabs4acoustic.com/recherche-t4a.html’
saved [91363]

--2019-03-04 10:01:04--
https://www.tabs4acoustic.com/images/design/t4a_mobile.png
Connecting to ****proxy_address****
(****proxy_address****)|XXX.XXX.XXX.XXX|:xxxx... connected.
Proxy request sent, awaiting response... 200 OK
Length: 1717 (1.7K) [image/png]
Saving to: ‘www.tabs4acoustic.com/images/design/t4a_mobile.png’

100%[===========================================================================>]
1,717       --.-K/s   in 0s

2019-03-04 10:01:04 (175 MB/s) - ‘
www.tabs4acoustic.com/images/design/t4a_mobile.png’ saved [1717/1717]

--2019-03-04 10:01:04--  https://www.tabs4acoustic.com/cours-guitare/
Connecting to ****proxy_address****
(****proxy_address****)|XXX.XXX.XXX.XXX|:xxxx... connected.
Proxy request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: ‘www.tabs4acoustic.com/cours-guitare/index.html’

    [
<=>
] 36,123      --.-K/s   in 0.02s

Last-modified header missing -- time-stamps turned off.
2019-03-04 10:01:04 (2.18 MB/s) - ‘
www.tabs4acoustic.com/cours-guitare/index.html’ saved [36123]

--2019-03-04 10:01:04--
https://www.tabs4acoustic.com/cours-guitare/theorie.html
Connecting to ****proxy_address****
(****proxy_address****)|XXX.XXX.XXX.XXX|:xxxx... connected.
Proxy request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: ‘www.tabs4acoustic.com/cours-guitare/theorie.html’

    [
<=>
] 69,973      --.-K/s   in 0.02s

Last-modified header missing -- time-stamps turned off.
2019-03-04 10:01:05 (3.19 MB/s) - ‘
www.tabs4acoustic.com/cours-guitare/theorie.html’ saved [69973]

--2019-03-04 10:01:05--
https://www.tabs4acoustic.com/cours-guitare/technique.html
Connecting to ****proxy_address****
(****proxy_address****)|XXX.XXX.XXX.XXX|:xxxx... connected.
Proxy request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: ‘www.tabs4acoustic.com/cours-guitare/technique.html’

    [
<=>
] 56,393      --.-K/s   in 0.02s

Last-modified header missing -- time-stamps turned off.
2019-03-04 10:01:05 (3.56 MB/s) - ‘
www.tabs4acoustic.com/cours-guitare/technique.html’ saved [56393]

--2019-03-04 10:01:05--
https://www.tabs4acoustic.com/cours-guitare/lutherie.html
Connecting to ****proxy_address****
(****proxy_address****)|XXX.XXX.XXX.XXX|:xxxx... connected.
Proxy request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: ‘www.tabs4acoustic.com/cours-guitare/lutherie.html’

    [
<=>
] 37,164      --.-K/s   in 0.003s

Last-modified header missing -- time-stamps turned off.
2019-03-04 10:01:05 (10.7 MB/s) - ‘
www.tabs4acoustic.com/cours-guitare/lutherie.html’ saved [37164]

--2019-03-04 10:01:05--
https://www.tabs4acoustic.com/cours-guitare/faq-debuter.html
Connecting to ****proxy_address****
(****proxy_address****)|XXX.XXX.XXX.XXX|:xxxx... connected.
Proxy request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: ‘www.tabs4acoustic.com/cours-guitare/faq-debuter.html’

    [
<=>
] 36,074      --.-K/s   in 0.003s

Last-modified header missing -- time-stamps turned off.
2019-03-04 10:01:05 (10.7 MB/s) - ‘
www.tabs4acoustic.com/cours-guitare/faq-debuter.html’ saved [36074]

[...]


Et voilà, le tour est joué,... j'ai pas fait un clone complet non plus, je
ne sait pas si il vas vraiment tout copier mais bon en tout cas il à l'air
de le faire...

Bien à la liste,...

Je ne le répète à chaque fois mait TOUT EST ECRIT ! RTFM ! :)

@pluche

On Sat, Mar 2, 2019 at 6:19 PM Manuel Schulte <manuel.schulte at gmail.com>
wrote:

> Aldo,
>
> Le site est en https, pas en http. En http, le site ne répond même pas...
> Maintenant, j'ai essayé et comme toi, wget ne récupère qu'une seule page,
> index.html dont le contenu est "DTC"...
> Comme informaticien, ces 3 lettres me parlent... pour moi cela veut dire
> "Dans Ton Cul"... en d'autres termes, le site ne se laisse pas télécharger
> par un "web scaper" comme wget ou autre.
>
> Plus sérieusement, il y a selon moi plusieurs hypothèses pour expliquer
> cela: primo, wget. D'après la man page, il respecte les instructions
> contenues dans le fichier robots.txt des sites qu'il parcourt. Si ce
> fichier contient des directives lui interdisant de ne pas suivre les liens,
> etc. cela expliquerait pourquoi wget ne télécharge rien d'autre qu'une page
> index.html (en général la page d'accueil par défaut). En outre, wget ne
> parcourra que le site du domaine spécifié, si le reste du site est sous un
> autre domaine, il ne sera pas téléchargé.
> Tu peux essayer --span-hosts ou -H, -rH, mais c'est dangereux car tu
> pourrais te retrouver à télécharger récursivement tout le contenu
> d'internet sur ta machine...
> détails ici:
> https://stackoverflow.com/questions/15434173/wget-downloads-only-one-index-html-file-instead-of-other-some-500-html-files
>
> A toi d'expérimenter un peu...
> Bonne chance et à++
>
> Manuel SCHULTE
> *Managing Director, Olympus Consulting sprl*
> *gsm :* +32(0)498 881 718
> *mail :* manuel.schulte at olympusconsulting.eu
> *web :* http://www.olympusconsulting.eu/
>
>
> Le jeu. 28 févr. 2019 à 10:54, Aldo <info at brlspeak.net> a écrit :
>
>> Bonjour à vous tous.
>>
>> Je voudrais savoir ce qui aurait changé avec wget, je n'arrive en effet
>> plus
>> du tout à télécharger une copie d'un site, que ce soit en utilisant
>> l'option
>> -m ou sa formulation --mirror.
>>
>> Je viens de lire un HowTo plus explicite, avec bcp plus d'options, eh bien
>> il ne veut tj rien faire,
>> se contente de repiocher la page index.html, c tout.
>>
>> Qq'un a une piste svp ?
>> Voir un autre outil que wget ?
>>
>> Sinon, je fais: wget -m http://tabs4acoustic.om/
>> (ou https://... mais ça ne change rien).
>>
>> Note: pour accéder à une info (ici un accord x ou y) j'ai déjà recours
>> obligatoire au lien In Cache du moteur de recherche, sinon même là
>> j'oublies.
>> Es-ce dû à Lynx ? Un ami m'indique qu'avec Firefox lui non plus n'a pas
>> accès au site.
>>
>> Vos lumières seront la bienvenue!
>>
>> Amicalement,
>>
>> Aldo.
>>
>> _______________________________________________
>> Linux-bruxelles :
>> Èchanger, partager, s'informer par mails sur toute action, proposition
>> accordée avec: http://www.bxlug.be/?Nos-statuts
>>
>> Linux-bruxelles at lists.bxlug.be
>> https://listes.domainepublic.net/listinfo/linux-bruxelles
>>
>> _______________________________________________
> Linux-bruxelles :
> Èchanger, partager, s'informer par mails sur toute action, proposition
> accordée avec: http://www.bxlug.be/?Nos-statuts
>
> Linux-bruxelles at lists.bxlug.be
> https://listes.domainepublic.net/listinfo/linux-bruxelles
>
>
-------------- section suivante --------------
Une pièce jointe HTML a été nettoyée...
URL: </pipermail/linux-bruxelles/attachments/20190304/6d30ee36/attachment-0002.html>


Plus d'informations sur la liste de diffusion Linux-bruxelles