2016-11-17 143 views
0

表單可以輸出google'search輸入的文本。如何編寫表單以從雅虎財務獲取搜索結果?

<form method="get" action="http://www.google.com/search"> 
<p class="nav"> 
<input size="-1" value="Search" type="submit"><br> 
<input name="q" size="16" maxlength="255" type="text"> 
<input name="sitesearch" value="www.example.com" type="hidden"> 
</p> 
</form> 

打開它與Firefox和輸入robot

enter image description here

要點擊搜索按鈕,我們得到的GOOGL的搜索結果。

enter image description here

一個問題在這裏:可以在google搜索引擎接收和<input name="sitesearch" value="www.example.com" type="hidden">處理參數?

現在我想獲得雅虎finace搜索結果以相同的形式,把它改寫爲

<form method="get" action="http://finance.yahoo.com/quote/"> 
<p class="nav"> 
<input size="-1" value="Search" type="submit"><br> 
<input name="q" size="16" maxlength="255" type="text"> 
</p> 
</form> 

時輸入fnma並點擊搜索BUTTOM我不能讓幹啥。

enter image description here enter image description here

如何改寫動作獲得與雅虎財經下面serch主頁結果?

enter image description here

回答

1

雅虎財經搜索不會出現相同的方式工作,因爲谷歌搜索一樣。

與你剛纔提到的Google一樣,你只需發送一個q = $ searchterm的GET變量,它會顯示結果,但是雅虎財經的搜索引擎似乎是在使用AJAX的頁面上完成的,這意味着你無法鏈接到它。當您鍵入查詢時,它將搜索到,而不會轉到單獨的頁面並將結果顯示爲搜索建議。

除非他們有一個API可用於搜索,然後我會想象這是不可能的,只是通過使用一個HTML表單。

+0

還有一個問題在這裏:谷歌搜索引擎可以接收並處理? –

+0

據我所知,這不是內置的。一種做法是將site:finance.yahoo.com + $ searchterm修改爲輸入。也許一個jQuery解決方案將是這樣做的最佳方式: – Hunter

+0

' Hunter