2016-11-17 138 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