سؤال

الآن أنه يمكنني التنقل في صفحة ويب عبر www :: ميكانيكي والحصول على المعلومات عبر < href="http://p3rl.org/html٪3A٪3atreebuilder٪3a٪3AXPATH" REL="nofollow"> HTML :: TreeBuilder :: XPath عن طريق الوصول إلى معرف، لقد تركت باستخدام firebug لقراءة DOM من أجل اكتشاف تخطيط شجرة HTML. المحتوى الذي يأتي القبض على HTML غير منظم، وليس جيدا للعيون البشرية. تستخدم

Firebug للتأكد من معرف I بعد نهج نموذجي؟ بمجرد أن أحصل على المعرف، فأنا على ما يرام، من الجيد أن أذهب، إنها فقط لدي العديد من المعرفات والصفحات مع مزيد من المعرفات لمطاردة وكنت آمل أن أحصل عليها (تفريغ أو طباعة، إلخ.) تخطيط منسق من أجل جعل هذا الاكتشاف أسهل. على الرغم من منحها، إلا أن Firebug يجعلها سهلة للغاية أيضا. أنا فقط أتساءل عما إذا كنت أفتقد طريقة أسهل.

p> crossposted في perlmonks.

هل كانت مفيدة؟

المحلول

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

نصائح أخرى

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top