html網(wǎng)頁超鏈接代碼 vba中怎么通過鏈接獲取網(wǎng)頁源碼?
vba中怎么通過鏈接獲取網(wǎng)頁源碼?有兩種方法,一種是使用ajax,另一種是啟動IE進程。我推薦方法一。我的示例代碼如下:dim HTTP set HTTP=CreateObject()Microsof
vba中怎么通過鏈接獲取網(wǎng)頁源碼?
有兩種方法,一種是使用ajax,另一種是啟動IE進程。我推薦方法一。我的示例代碼如下:
dim HTTP set HTTP=CreateObject()Microsoft.XMLHTTP") http.打開“Post”,“connection address”,falsehttp.send發(fā)送“”如果http.狀態(tài)=200那么selection.text=http.responseText End If
如何抓取網(wǎng)頁代碼中的URL?
以下代碼可以獲取指定URL頁中的所有鏈接,即,所有a標(biāo)記的a屬性://獲取鏈接的HTML代碼$HTML=filegetcontents(”http://www.example.com“”$dom=new DOMDocument()@$dom->loadHTML($html)$xpath=new DOMXPath($dom)$hrefs=$xpath->evaluate(“/html/body//a”)for($i=0$i length$i){$href=$hrefs->item($i)$url=$href->getAttribute(“href”)echo$url?!啊眪此代碼將獲取所有a-tag的a-tag的a-tag的a-tag的a-tag的a-tag的a-tag的a-tag的a-tag的a-tag的a-tag的a-tag的a-tag的a-tag的a-tag的a-tag的a-tag的a-tag的a-tag的a-tag的a-tag的a-tag內(nèi)容(”http://www.example.com“”$DOM=new domdocument()@$DOM->loadhtml($HTML)$XPath=new domxpath($DOM)$hrefs=$XPath->evaluate(“/HTML/body//a”)for($I=0$I length$I){U.S.=$hrefs->item($I)$url=$U.S.=$U.S.->getattribute(“U.S.”)//保留以HTTP if開頭的鏈接(substr($url,0,4)==“HTTP”)echo$url。"}