Pages : 1
#1 Le 20/01/2014, à 10:00
- Oma
scroll site web
Bonjour,
je viens vers pour car je n'avance pas.
je cherche a lister les liens de quelques sites un peu comme xenu.
je me penche sur wget et httrack mais ..... je n'y arrive pas.
avez vous une idée?
Merci
Hors ligne
#2 Le 20/01/2014, à 10:16
- k3c
Re : scroll site web
Bonjour
Je pense que un autre forum serait plus adapté.
En Python, après avoir installé BeautifulSoup4
sudo apt-get install python-bs4
tu lances le script suivant
import urllib
import BeautifulSoup
html = urllib.urlopen('http://forum.ubuntu-fr.org').read()
s = BeautifulSoup.BeautifulSoup()
s.feed(html)
for i in s('a'):
try:
print i['href']
except:
pass
Debian 12 sur Thinkpad reconditionné
Hors ligne
#3 Le 20/01/2014, à 10:22
- Oma
Re : scroll site web
Voila une petite erreur
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 335: ordinal not in range(128)
Hors ligne
#4 Le 20/01/2014, à 10:31
- k3c
Re : scroll site web
ah oui, un scriptPython doit commencer par
#!/usr/bin/python
#-*- coding:utf-8 -*-
Debian 12 sur Thinkpad reconditionné
Hors ligne
#5 Le 20/01/2014, à 10:34
- Oma
Re : scroll site web
ca ne change rien!!!
Hors ligne
#6 Le 20/01/2014, à 11:10
- k3c
Re : scroll site web
si tu dis quel site tu veux accéder ça pourrait aider...
Debian 12 sur Thinkpad reconditionné
Hors ligne
#7 Le 20/01/2014, à 14:12
- Oma
Re : scroll site web
re, je fais un test avec le site http://ardeche.fr
url.py est mon fichier.
Traceback (most recent call last):
File "url.py", line 9, in <module>
s.feed(html)
File "/usr/lib/python2.7/sgmllib.py", line 103, in feed
self.rawdata = self.rawdata + data
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe8 in position 301: ordinal not in range(128)
Hors ligne
#8 Le 20/01/2014, à 14:30
- k3c
Re : scroll site web
Dans le source de ardeche.fr
il y a
content="text/html; charset=ISO-8859-1"
Tu devrais lire
http://www.crummy.com/software/Beautifu … ode-dammit
Debian 12 sur Thinkpad reconditionné
Hors ligne
#9 Le 20/01/2014, à 14:34
- k3c
Re : scroll site web
Si ton script commence par
#!/usr/bin/python
# -*- coding: iso-8859-1 -*-
est-ce que ça marche mieux ?
Debian 12 sur Thinkpad reconditionné
Hors ligne
#10 Le 21/01/2014, à 13:58
- Oma
Re : scroll site web
Marche pas..… je ne comprends pas....
Hors ligne
#11 Le 21/01/2014, à 14:05
- k3c
Re : scroll site web
Je te posterai un script dans la journée
Debian 12 sur Thinkpad reconditionné
Hors ligne
#12 Le 21/01/2014, à 14:12
- Oma
Re : scroll site web
Je regarde avec lynx mais ça marche une fois sur deux....
Hors ligne
#13 Le 21/01/2014, à 19:10
- k3c
Re : scroll site web
Le script suivant marche
#!/usr/bin/python
#-*- coding:utf-8 -*-
from __future__ import unicode_literals
import urllib
import BeautifulSoup
import re
html = urllib.urlopen('http://ardeche.fr').read()
s = BeautifulSoup.BeautifulSoup(html)
for i in s.findAll('a'):
try:
print i['href']
except:
pass
Il affiche
g@vientiane:~$ python ardeche1.py
http://ardeche.fr/rss
http://ardeche.fr/marches-publics
http://ardeche.fr
http://ardeche.fr/plan-site
http://ardeche.fr/faq
http://ardeche.fr/contact
http://ardeche.fr
http://ardeche.fr/Coup_de_pouce
http://ardeche.fr/Actualite
http://ardeche.fr/Action_sociale
http://ardeche.fr/Culture
http://ardeche.fr/Economie
http://ardeche.fr/Education-Jeunesse
http://ardeche.fr/Environnement
http://ardeche.fr/Routes
http://ardeche.fr/Sports
http://ardeche.fr/Transport
#
http://ardeche.fr/Actualite/A_la_une
http://ardeche.fr/Actualite/Ca_bouge
http://ardeche.fr/Actualite/Ca_bouge?n=0#1
http://ardeche.fr/Actualite/Zoom_sur
http://ardeche.fr/Actualite
http://ardeche.fr/Le_territoire__l_institution
http://ardeche.fr/Ardeche_des_idees_forces
http://ardeche.fr/A_consulter
http://ardeche.fr/Action_sociale
http://ardeche.fr/Culture
http://ardeche.fr/Economie
http://ardeche.fr/Education-Jeunesse
http://ardeche.fr/Environnement
http://ardeche.fr/Routes
http://ardeche.fr/Sports
http://ardeche.fr/Transport
http://ardeche.fr?print=1
notify_friend_form?url=http://ardeche.fr/
gg@vientiane:~$
Debian 12 sur Thinkpad reconditionné
Hors ligne
Pages : 1