Question

Maintenant que je peux naviguer sur une page Web via www :: mécanise et obtenir des informations via < un href="http://p3rl.org/html%3a%3atreeBuilder%3a%3Axpath" rel="nofollow"> html :: TreeBuilder :: XPath en accédant à un identifiant, je suis laissé en utilisant Firebug Pour lire le DOM afin de découvrir la mise en page de l'arbre HTML. Le contenu qui mécanise les captures est non structuré HTML, pas bon pour les yeux humains.

Utilise Firebug pour déterminer l'ID que je suis après une approche typique? Une fois que je reçois l'identifiant, je suis bon d'y aller, c'est juste que j'ai plusieurs identifiants et pages avec plus d'identifiants pour chasser et j'espérais obtenir (décharge, impression, etc.) une disposition formatée du DOM afin de faciliter cette découverte. Bien que accordé, Firebug le rend assez facile aussi facile. Je me demande simplement si je manque une méthode plus facile.

CrossPosted à Perlmonks.

Était-ce utile?

La solution

If you need text, xmllint --html --format (comes with libxml2) does a decent job.

If you want a tree and mess with it and test out various expressions in a GUI, then Xacobeo is your new best friend.

Xacobeo screenshot

Note: since both those tools rely on libxml, replace HTML::TreeBuilder::XPath with HTML::TreeBuilder::LibXML for compatibility. Evaluating XPath will be faster that way, too.


If you know Javascript/JQuery, then also install FireQuery. You can then test out CSS expressions in FireBug, and use them with modules that select HTML through CSS expressions, e.g. Web::Query.

FireQuery screenshot

Autres conseils

I use XML Developer from Oxygen IDE for my recent development on XPath: http://www.oxygenxml.com/download.html It is a 30-day trial type of tool, but you can also search for XPath visualizer

It doesn't visualize a tree for you as far as I know (maybe there's a panel doing that). But it gives you some smart complete functionally that helps you to know what nodes you have available at any point. It is pretty big for XPath because it is hard to know where the parser pivot is really pointing at.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top