<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>网络编程 &#187; 网页元素数量</title>
	<atom:link href="http://www.sdgz.cn/tag/%e7%bd%91%e9%a1%b5%e5%85%83%e7%b4%a0%e6%95%b0%e9%87%8f/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.sdgz.cn</link>
	<description>PHP RUBY</description>
	<lastBuildDate>Tue, 03 Aug 2010 17:14:20 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.4</generator>
		<item>
		<title>watir中统计网页中链接数量的语句</title>
		<link>http://www.sdgz.cn/watir-number-of-statistical-links-page-statement/</link>
		<comments>http://www.sdgz.cn/watir-number-of-statistical-links-page-statement/#comments</comments>
		<pubDate>Thu, 07 Jan 2010 09:25:06 +0000</pubDate>
		<dc:creator>leleba</dc:creator>
				<category><![CDATA[watir]]></category>
		<category><![CDATA[网页元素数量]]></category>

		<guid isPermaLink="false">http://www.sdgz.cn/watir-number-of-statistical-links-page-statement/</guid>
		<description><![CDATA[有时候需要统计网页中或者网页某个区域中的链接数量，刚开始我尝试以下语句，但不成功： ie.links(:id, /bra bra/).length 后来发现以下语句可行： ie.div(:id, &#8220;searchList&#8221;).links 之后发现如下更好的语句： links_searchlist = ie101.links.find_all { &#124;link&#124; link.class_name == &#8216;permalink&#8217; } puts &#8220;the links in the searchlist:&#8221; puts links_searchlist.length searchlistlinks = ie102.links.find_all { &#124;link&#124; link.id =~ /hitURL/ } links_searchlist = searchlistlinks.length puts links_searchlist searchlistlinks = ie33.links.find_all { &#124;link&#124; link.href =~ /something/ } 类似的语句不行：searchlistlinks = ie33.links.find_all { &#124;link&#124; link.url =~ [...]]]></description>
			<content:encoded><![CDATA[<p>有时候需要统计网页中或者网页某个区域中的链接数量，刚开始我尝试以下语句，但不成功： <br/>ie.links(:id, /bra bra/).length</p>
<p>后来发现以下语句可行： <br/>ie.div(:id, &#8220;searchList&#8221;).links</p>
<p>之后发现如下更好的语句：</p>
<p>links_searchlist = ie101.links.find_all { |link| link.class_name == &#8216;permalink&#8217; } <br/>puts &#8220;the links in the searchlist:&#8221; <br/>puts links_searchlist.length</p>
<p>          <br/>searchlistlinks = ie102.links.find_all { |link| link.id =~ /hitURL/ } <br/>links_searchlist = searchlistlinks.length <br/>puts links_searchlist</p>
<p>searchlistlinks = ie33.links.find_all { |link| link.href =~ /something/ } <br/>类似的语句不行：searchlistlinks = ie33.links.find_all { |link| link.url =~ /something/ }</p>
<p>最近发现，如果链接数量比较多，以上语句耗时太长，通过google和百度，找到了更高效的语句：</p>
<p>links = ie51.div(:id, &#8216;threadlist&#8217;).html.scan(/something/).count <br/>puts links</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sdgz.cn/watir-number-of-statistical-links-page-statement/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

