白杨 发表于 2015-3-13 15:01:32

[已解决]关于使用正则表达式提取返回网页中关键字符串所在行的问题

本帖最后由 白杨 于 2015-3-16 16:15 编辑

<pre>   Domain Name: BAIDU.COM
   Registrar: MARKMONITOR INC.
   Sponsoring Registrar IANA ID: 292
   Whois Server: whois.markmonitor.com
   Referral URL: http://www.markmonitor.com
   Name Server: DNS.BAIDU.COM
   Name Server: NS2.BAIDU.COM
   Name Server: NS3.BAIDU.COM
   Name Server: NS4.BAIDU.COM
   Name Server: NS7.BAIDU.COM
   Status: clientDeleteProhibited http://www.icann.org/epp#clientDeleteProhibited
   Status: clientTransferProhibited http://www.icann.org/epp#clientTransferProhibited
   Status: clientUpdateProhibited http://www.icann.org/epp#clientUpdateProhibited
   Status: serverDeleteProhibited http://www.icann.org/epp#serverDeleteProhibited
   Status: serverTransferProhibited http://www.icann.org/epp#serverTransferProhibited
   Status: serverUpdateProhibited http://www.icann.org/epp#serverUpdateProhibited
   Updated Date: 14-oct-2013
   Creation Date: 11-oct-1999
   Expiration Date: 11-oct-2015

&gt;&gt;&gt; Last update of whois database: Wed, 11 Mar 2015 15:57:28 GMT &lt;&lt;&lt;
</pre>
<p>Queried <span class="ipaddr">whois.markmonitor.com</span> with "<span class="ipaddr">baidu.com</span>"...</p>
<pre>Domain Name: baidu.com
Registry Domain ID: 11181110_DOMAIN_COM-VRSN
Registrar WHOIS Server: whois.markmonitor.com
Registrar URL: http://www.markmonitor.com
Updated Date: 2014-08-20T04:00:52-0700
Creation Date: 1999-10-11T04:05:17-0700
Registrar Registration Expiration Date: 2015-10-11T04:05:17-0700
Registrar: MarkMonitor, Inc.
Registrar IANA ID: 292
Registrar Abuse Contact Email: abusecomplaints@markmonitor.com
Registrar Abuse Contact Phone: +1.2083895740
Domain Status: clientUpdateProhibited (https://www.icann.org/epp#clientUpdateProhibited)
Domain Status: clientTransferProhibited (https://www.icann.org/epp#clientTransferProhibited)
Domain Status: clientDeleteProhibited (https://www.icann.org/epp#clientDeleteProhibited)
Registry Registrant ID:
Registrant Name: Zhiyong Duan
Registrant Organization: Beijing Baidu Netcom Science Technology Co., Ltd.
Registrant Street: 3F Baidu Campus No.10, Shangdi 10th Street Haidian District
Registrant City: Beijing
Registrant State/Province: Beijing
Registrant Postal Code: 100085
Registrant Country: CN
Registrant Phone: +86.1059924216
Registrant Phone Ext:
Registrant Fax: +86.1059927435
Registrant Fax Ext:
Registrant Email: domainmaster@baidu.com
Registry Admin ID:
Admin Name: Zhiyong Duan
Admin Organization: Beijing Baidu Netcom Science Technology Co., Ltd.
Admin Street: 3F Baidu Campus No.10, Shangdi 10th Street Haidian District
Admin City: Beijing
Admin State/Province: Beijing
Admin Postal Code: 100085
Admin Country: CN
Admin Phone: +86.1059924216
Admin Phone Ext:
Admin Fax: +86.1059927435
Admin Fax Ext:
Admin Email: domainmaster@baidu.com
Registry Tech ID:
Tech Name: Zhiyong Duan
Tech Organization: Beijing Baidu Netcom Science Technology Co., Ltd.
Tech Street: 3F Baidu Campus No.10, Shangdi 10th Street Haidian District
Tech City: Beijing
Tech State/Province: Beijing
Tech Postal Code: 100085
Tech Country: CN
Tech Phone: +86.1059924216
Tech Phone Ext:
Tech Fax: +86.1059927435
Tech Fax Ext:
Tech Email: domainmaster@baidu.com
Name Server: ns3.baidu.com
Name Server: ns7.baidu.com
Name Server: dns.baidu.com
Name Server: ns4.baidu.com
Name Server: ns2.baidu.com
DNSSEC: unsigned
URL of the ICANN WHOIS Data Problem Reporting System: http://wdprs.internic.net/
&gt;&gt;&gt; Last update of WHOIS database: 2015-03-11T08:50:20-0700 &lt;&lt;&lt;
</pre>
这是我用IE.au3中的$oHTTP.responseText获得的部分网页的源码,源码如下$return=BinaryToString($oHTTP.responseText)
$a = StringRegExp($return,'\Registrant Street:(.+?)\ & @CRLF', 1)我现在想提取出诸如Admin Name后面的信息并显示出来,刚学autoit的小白,看来大神们的帖子看了半天也才把网页返回回来,剩下的就两眼一抹黑了。

白杨 发表于 2015-3-13 15:56:52

我贴的代码太长了,其实就是解决一个用正则表达式来获取每行相应信息的问题

半芯竹 发表于 2015-3-13 17:41:07

我不是很理解,你具体想要哪些内容。。

Huiseyu 发表于 2015-3-13 17:50:03

我不是很理解,你具体想要哪些内容。。
半芯竹 发表于 2015-3-13 17:41 http://www.autoitx.com/images/common/back.gif


.Admin Name: Zhiyong Duan    他想要的应该是这个 ,正则太难了....

半芯竹 发表于 2015-3-13 18:18:44

回复 4# Huiseyu


    那就更简单了。。Admin Name: (.*)这样就完了。
应该不止是这样,其它信息他还想要的。。

haijie1223 发表于 2015-3-13 18:21:26

Admin Name:\s(.*?)\n

白杨 发表于 2015-3-16 09:45:17

回复 6# haijie1223


   用msgbox返回是1?

白杨 发表于 2015-3-16 09:50:23

回复 6# haijie1223


#include <IE.au3>
#include <Array.au3>
$oHTTP = ObjCreate("microsoft.xmlhttp")
$oHTTP.Open("post","http://centralops.net/co/DomainDossier.aspx",false)
$oHTTP.setRequestHeader("Cache-Control", "no-cache")
$oHTTP.setRequestHeader("Content-Type","application/x-www-form-urlencoded")
$oHTTP.setRequestHeader("Referer","http://centralops.net/co/body")
$oHTTP.setRequestHeader("Accept-Encoding","gzip, deflate")
$oHTTP.setRequestHeader("User-Agent","Mozilla/5.0 (Windows NT 6.1; WOW64; rv:36.0) Gecko/20100101 Firefox/36")
$oHTTP.Send("addr=google.com&go.x=12&go.y=12&dom_dns=1&dom_whois=1&net_whois=1")
$return=BinaryToString($oHTTP.responsebody)
$array = StringRegExp($return, 'Admin Name:\s(.*?)\n',1)
_ArrayDisplay($array,"_ArrayDisplay() Test")
使用了arraydisplay返回值居然是DNS Admin

nchxzy 发表于 2015-4-6 12:06:11

具体想要哪些内容。。/???
页: [1]
查看完整版本: [已解决]关于使用正则表达式提取返回网页中关键字符串所在行的问题