该脚本用来访问一个url,并取出相应结果(该脚本用来通过淘宝API实现判断一个IP所在地)

 1 #定义要访问的URL
 2 $url="http://ip.taobao.com/service/getIpInfo.php?ip=8.8.8.8"
 3 
 4 #定义函数:等待页面打开
 5 function WaitForLoad($ie)
 6 {
 7  sleep 2
 8  do {Sleep -Mi 200}
 9  while ($ie.busy)
10 }
11 
12 $ie = new-object -com "InternetExplorer.Application"
13 $ie.navigate($url)
14 $ie.visible=$false
15 WaitForLoad $ie
16 #取页面返回结果
17 $ie.Document.body.innerText
18 $ie.Quit()

返回结果:

{"code":0,"data":{"country":"\u7f8e\u56fd","country_id":"US","area":"","area_id":"","region":"","region_id":"","city":"","city_id":"","county":"","county_id":"","isp":"","isp_id":"","ip":"8.8.8.
8"}}

IE自动化 二(判断IP所在地)_返回结果