如何使用<select> </select>为网站创建搜索URL

时间:2011-12-12 18:20:02

标签: html url search search-engine

我正在编写一些代码,用于搜索网站并返回搜索结果的数量。有点像Number of Google Results from Excel,但我使用的网站是sciencedirect.com

科学直接有点奇怪,因为结果页面的网址不包含搜索字词,因此找到发送搜索字词的网址会更复杂。我一直在阅读高级搜索页面的源代码,这是代码的相关部分:

 <form name="Form1" method="get" action="/science">
    <input type="hidden" name="_ob" value="MiamiSearchURL">
    <input type="hidden" name="_method" value="submitForm">
    <input type="hidden" name="_acct" value="C000053194">



    <input type="hidden" name="_temp" value="all_search.tmpl">


    <input type="hidden" name="md5" value="9e299e9289462d7805ab0a5dcc9cff5c">
    <input type="hidden" name="test_alid" value="">

 <div class="contentMain" style="margin:1px 0 0 1px;"><div class="contentShadow"><div class="contentBorders"> 

 <div class="searchFormBg">
   <div style="text-align:right;">
   <a href="/science?_ob=HelpURL&_file=stadv_main_all.htm&_acct=C000053194&_version=1&_urlVersion=0&_userid=1495569&md5=77d715b68200140e79de4e6c4228507e" target="sdhelp" onClick="var helpWin; helpWin=window.open('/science?_ob=HelpURL&_file=stadv_main_all.htm&_modifyAlert=Y&_acct=C000053194&_version=1&_urlVersion=0&_userid=1495569&md5=5aa55cdf2635b42c8858e3379a022f8d','sdhelp','scrollbars=yes,resizable=yes,directories=no,toolbar=no,menubar=no,status=no,width=760,height=570'); helpWin.focus()" class="noul icon_qmarkHelpsci_dir">Search tips</a>

   </div>
      <div>        
        <a name="Skip Search"></a><label class="searchFormLabel" for="SearchText">Search&nbsp;</label>
        <input type="text" class="inputBox" name="SearchText" id="SearchText" value="" size="60" maxlength="256">&nbsp;&nbsp;in&nbsp;&nbsp;
          <select name="keywordOpt" id="keywordOpt" size="1">
          <option value="ALL"   selected >All Fields</option>
          <option value="TITLE-ABSTR-KEY" >Abstract, Title, Keywords</option>
          <option value="AUTHORS" >Authors</option>
          <option value="SPECIFIC-AUTHOR" >Specific Author</option>
          <option value="SRCTITLEPLUS" >Source Title</option>
          <option value="TITLE" >Title</option>
          <option value="KEYWORDS" >Keywords</option>
          <option value="ABSTRACT" >Abstract</option>
          <option value="REFERENCES" >References</option>
          <option value="ISSN" >ISSN</option>
          <option value="ISBN" >ISBN</option>
          <option value="AFFILIATION" >Affiliation</option>
          <option value="FULL-TEXT" >Full Text</option>
          </select>
      </div>
      <div class="searchFormField">
      <select name="addTerm" id="addTerm" size="1">
          <option value="0"  selected > AND
          <option value="1" > OR
          <option value="2" > AND NOT
          </select>
      </div>
      <div>
         <input type="text" class="inputBox" name="addSearchText" id="addSearchText" value="" size="60" maxlength="256">&nbsp;&nbsp;in&nbsp;&nbsp;
          <select name="addkeywordOpt" id="addkeywordOpt" size="1">
          <option value="ALL"   selected >All Fields</option>
          <option value="TITLE-ABSTR-KEY" >Abstract, Title, Keywords</option>
          <option value="AUTHORS" >Authors</option>
          <option value="SPECIFIC-AUTHOR" >Specific Author</option>
          <option value="SRCTITLEPLUS" >Source Title</option>
          <option value="TITLE" >Title</option>
          <option value="KEYWORDS" >Keywords</option>
          <option value="ABSTRACT" >Abstract</option>
          <option value="REFERENCES" >References</option>
          <option value="ISSN" >ISSN</option>
          <option value="ISBN" >ISBN</option>
          <option value="AFFILIATION" >Affiliation</option>
          <option value="FULL-TEXT" >Full Text</option>
          </select>
      </div>
      <div style="margin:5px 0;">
      <label class="searchFormLabel" for="source">Include</label>


            <div style="float:left;"><input style="cursor: pointer;" type="checkbox" id="journals" name="source" value="srcJrl" CHECKED></div><div style="float:left;padding-top:2px;margin-right:5px;" class="astPad"><label for="journals">Journals</label></div>


            <div style="float:left;"><input style="cursor: pointer;" type="checkbox" id="books" name="source" value="srcBk" CHECKED></div><div style="float:left;padding-top:2px;margin-right:5px;" class="astPad"><label for="books">All Books</label></div>


      </div>    
      <div style="clear:both;"></div>

      <div>
      <label class="searchFormLabel" for="Subscribed">Source</label>
         <select name="Subscribed" id="Subscribed" size="1" onChange="checkFavoriteJournals(this, 'sources','Y', '');" style="width:200px;">

          <option value="0" SELECTED>All sources</option>


          <option value="1" >Subscribed sources</option>


          <option value="2" >My Favorite sources</option>

        </select>
      </div>      


       <div style="clear:both;"></div>
      <div>
      <label class="searchFormLabel" for="Subject">Subject&nbsp;<span class="SDtxtNoteSmall">(select one or more)</span></label></div>
      <div>
      <div style="margin-right:10px;display:inline;float:left;"><SELECT Name="srcSel" Multiple Size = "4"><OPTION VALUE="1" SELECTED > - All Sciences -<OPTION VALUE="5"> Agricultural and Biological Sciences<OPTION VALUE="6"> Arts and Humanities<OPTION VALUE="18"> Biochemistry, Genetics and Molecular Biology<OPTION VALUE="7"> Business, Management and Accounting<OPTION VALUE="8"> Chemical Engineering<OPTION VALUE="9"> Chemistry<OPTION VALUE="11"> Computer Science<OPTION VALUE="12"> Decision Sciences<OPTION VALUE="13"> Earth and Planetary Sciences<OPTION VALUE="14"> Economics, Econometrics and Finance<OPTION VALUE="15"> Energy<OPTION VALUE="16"> Engineering<OPTION VALUE="17"> Environmental Science<OPTION VALUE="220"> Immunology and Microbiology<OPTION VALUE="19"> Materials Science<OPTION VALUE="20"> Mathematics<OPTION VALUE="21"> Medicine and Dentistry<OPTION VALUE="22"> Neuroscience<OPTION VALUE="466"> Nursing and Health Professions<OPTION VALUE="23"> Pharmacology, Toxicology and Pharmaceutical Science<OPTION VALUE="24"> Physics and Astronomy<OPTION VALUE="25"> Psychology<OPTION VALUE="26"> Social Sciences<OPTION VALUE="487"> Veterinary Science and Veterinary Medicine</SELECT></div>
      <div class="txtSmall" style="display:inline;">Hold down the Ctrl key (or Apple Key) <br>to select multiple entries.</div>
      </div>
       <div style="clear:both;"></div>

由此我构建了这个URL http://www.sciencedirect.com/science?_ob=MiamiSearchURL&_method=submitForm&_acct=C000053194&_temp=all_search.tmpl&md5=9e299e9289462d7805ab0a5dcc9cff5c&test_alid=&keywordOpt=TITLE-ABSTR-KEY&source=srcJrl=1&source=srcBk=1&Subscribed=0&onchange=Y&srcSel=1&DateOpt=2&SearchText=test

适用于&amp; [inputname] = [value]&amp;基础

哪个应该根据我的标准搜索“测试”,不幸的是它会返回一个错误“必须选择一个来源”,该源设置为URL的Subscribed = 0部分并且似乎正在工作,因为更改值会发生变化来源。

源和其他字段之间的区别在于源是否使用

所以我的问题是如何更改网址以便返回结果。

1 个答案:

答案 0 :(得分:0)

看起来科学直接使用每个搜索具有唯一值的变量(在您的示例中为md5 = 9e299e9289462d7805ab0a5dcc9cff5c)。即使您执行相同的搜索,此值也会更改。

我没有做过任何详细的调查,但是如果他们在他们身边做了一些检查(例如检查cookies,IP地址等),那么即使不是不可能,也很难。