0
我正在使用vba(& internetexplorer对象)从以下网站http://www.isincodes.net/convert-cusip-to-isin.php将CSUIP转换为ISIN(这些是金融安全唯一标识码)。VBA简单解析
我迄今所创建的VBA代码(按照以下顺序)认为: 1.操纵美国/加拿大下拉框中 2.输入我的CUSIP到输入框 3.点击“隐蔽”按钮
Sub cusip_is2()
'declare variables
Set objie = CreateObject("internetExplorer.Application")
objie.Visible = True
'go to website
objie.navigate ("http://www.isincodes.net/convert-cusip-to-isin.php")
Do
DoEvents
Loop Until objie.readyState = 4
'input the CA in the country ID step1
objie.document.getelementbyID("country").Value = "CA"
'input 912796HQ5 in text box as desired CUSIP to convert
objie.document.getelementbyID("appendedInputButton").Value = "912796HQ5"
'press the button to convert
Set ElementCol = objie.document.getElementsByTagName("button")
For Each btnInput In ElementCol
btnInput.Click
Next btnInput
'wait until the pages loads (not sure if I need this)
Do
DoEvents
Loop Until objie.readyState = 4
'added extra few seconds incase HMTL document is updating
Application.Wait Now + TimeSerial(0, 0, 1)
'created userform to look at the data to see if I can find the converted CUSIP - WHICH I CANNOT (HELPPPPP!!!!)
Userfrom_Web_Code.Textbox_Webform.Text = objie.body.innerText
Userfrom_Web_Code.Show
'clean up and try again for the next failure LOL
objie.Quit
Set objie = Nothing
End Sub
从我的研究中,我知道我一直在获取源代码,但是我想要DOM,这是我遇到问题的地方。一旦我为国家和CUSIP“912796HQ5”输入了“CA”,请参阅网站上的源代码摘录,并注意带结果的id标记不包含任何内容。
<p>Enter a CUSIP and a correct ISIN will be calculated for you, if possible:</p>
<form class="form-inline">
<div class="input-append">
<select id="country" style="width:60px;">
<option value="CA">CA</option>
<option value="US" selected>US</option>
</select>
<input type="text" maxlength="9" class="span3" id="appendedInputButton">
<button type="button" class="btn">Convert</button>
</div>
</form>
<div id="results"></div>
<br><br>
</div>
<div class="span4">
<h4>What is a CUSIP?</h4>
<p>A CUSIP is a 9-character alphanumeric code which identifies a North American financial security.</p>
<p>
A CUSIP consists of three parts:<br>
• A six-character issuer code<br>
• A two-character issue number<br>
• A single check digit.<br><br>
For example: 780259206 (Royal Dutch Shell-A)
</p>
相反,当我检查检查元件,它带我到“DOM”那么我可以在ID结果看到这一点。
<div id="results" style="display: block;"><br>
<b>Strict Standards</b>: Non-static method Validate_CUSIP::validate() should not be called statically in <b>/home/isincode/public_html/action/c.php</b> on line <b>15</b><br>
<p class="text-success"><strong>Correct ISIN: CA912796HQ58</strong></p></div>
任何人都可以请帮我在VBA解决这个问题。
请注意,我知道你可以在vba/excel中自己创建一个算法来完成CUSIP到ISIN的转换,但是我想在VBA中做这个项目来学习解析。我对编码也很陌生,接触有限,请善待并解释你所建议的一切。
嘿Carmelid,似乎是工作我家里的电脑上,将尝试并且在我的工作中,我遇到了一个问题。不能相信这只是LOL的一秒钟。非常感谢您的时间也是为了。 – deltahedge