如何通过它的类来抓取一个元素,并说出它是否包含一个大于 [英] How to grab an element by it class, and saying if it contains a number greater than

查看:111
本文介绍了如何通过它的类来抓取一个元素,并说出它是否包含一个大于的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

伙计们

我只是想知道是否有人可以帮助我解决我遇到的问题.基本上,我想做的是通过其类名从WebPage抓取一个元素,并使Vb自动查找以查看是否有大于该元素内包含的数字.我有下面的html代码.

Hi Guys

I was just wondering if anybody can help me with a problem i have been having. Basically what i am trying to do is grab an element off a WebPage by it''s class name and make Vb automatically look up to see if there is a number greater than what is contained within the element. I have the html code below.

0



因此,就我而言,我想说的是

如果classname ="mam_limit_num")且包含整数> 0
然后做些什么



大家有什么建议.

预先谢谢您.



So in my case i am wanting to say something like

if classname = "mam_limit_num") and contains an integer >0
then do something



Any suggestions here guys.

Thank You In Advance.

推荐答案

问题非常非常不清楚.请参阅我对这个问题的评论.

但也许甚至是初步说明也可以帮助您解决问题.

如果这是ASP.NET,并且您在谈论CSS类,则可以将JavaScript与jQuery一起使用,使用选择器".class"或使用CSS方法.请参阅:
http://api.jquery.com/class-selector/ [ http://api.jquery.com/category/selectors/ [ http://api.jquery.com/category/css/ [ http://api.jquery.com/hasClass/ [ http://docs.jquery.com/Tutorials:How_jQuery_Works [ http://msdn.microsoft.com/en-us/library/system.object. gettype.aspx [^ ].

而且您不需要比较类型名称(实际上,您永远都不要这样做),您应该使用"=="运算符来比较System.Type本身的实例.要在考虑继承的情况下按类型比较两个引用,您需要使用Is运算符:
http://msdn.microsoft.com/en-us/library/kb136x1y.aspx [ ^ ].

您应该非常了解.NET类型系统,因为这是最重要的.但是,您应该了解按对象类型比较以提供不同功能的第一件事:这是对OOP的巨大根本性滥用,这完全挫败了OOP方法.不要这样相反,请学习OOP的工作原理.

因此,如果您对该答案不太满意,则应正确解释您要实现的目标.首先说明您的最终目标. 我很确定真正的解决方案不会基于类型比较.



感谢您的澄清,但是它们仍然不是100%清晰,因此您应该首先进行解释. .NET中没有预安装的XML解析器.如果这是HTML格式正确的XML代码,那么您很幸运,可以使用任何可用的XML解析器.如果不是这种情况,则需要一些HTML解析器来处理.您可以使用此一个:
http://www.majestic12.co.uk/projects/html_parser.php [ ^ ].

—SA
The question is very, very unclear. Please see my comment to the question.

But perhaps even preliminary notes will help you to solve the problem.

If this is ASP.NET and you are talking about CSS class, you can use JavaScript with jQuery with either the selector ".class" or using CSS methods. Please see:
http://api.jquery.com/class-selector/[^],
http://api.jquery.com/category/selectors/[^],
http://api.jquery.com/category/css/[^],
http://api.jquery.com/hasClass/[^].

If you need to learn jQuery, this is a good start:
http://docs.jquery.com/Tutorials:How_jQuery_Works[^].

If you are talking about .NET classes: every object of all type (both reference and value types) can use the method GetType, because this is the method of System.Object which is a base class for all types:
http://msdn.microsoft.com/en-us/library/system.object.gettype.aspx[^].

And you don''t need to compare type names (actually, you should never do it), you should compare instances of System.Type themselves, using the "==" operator. To compare two references by type taking into account the inheritance, you need to use the Is operator:
http://msdn.microsoft.com/en-us/library/kb136x1y.aspx[^].

You should really understand .NET type system very well, as this is the most important thing. But first thing you should understand about comparison of object by their type to provide different functionality: this is the huge fundamental abuse of OOP, something that totally defeats OOP approach. Don''t do it. Instead, learn how OOP works.

So, if you are not quite satisfied with this answer, you should explain properly what do you want to achieve. Start with explanation of your ultimate goals. I''m quite sure the real solution will not be based on type comparison.



Thank you for clarification, but they are still not 100% clear, and you should have explained it in first place. There is no pre-installed XML parser in .NET. If this is an HTML code well-formed as XML, you are lucky, can use any available XML parser. If this is not the case, you will need some HTML parser which can deal with that. You can use this one:
http://www.majestic12.co.uk/projects/html_parser.php[^].

—SA


这篇关于如何通过它的类来抓取一个元素,并说出它是否包含一个大于的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆