Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Excel中的搜索结果数_Excel_Vba_Web Scraping - Fatal编程技术网

Excel中的搜索结果数

Excel中的搜索结果数,excel,vba,web-scraping,Excel,Vba,Web Scraping,给定一列字符串,我想从一个网站(如sciencedirect.com)查找每个字符串的搜索结果数。现有的答案对谷歌来说很有效 不幸的是,此解决方案从字符串创建搜索URL,例如,Google搜索包含单词example。我想使用的网站不这样做 例如,搜索返回URL 你知道我是如何用这种搜索引擎得到同样的结果的吗 单击搜索按钮时,您必须检查提交的表单。表单发送一个GET请求,其中包含搜索词,但随后您将被重定向到结果列表页面,并且结果页面的URL不再包含搜索词 我已使用此URL成功搜索语料库: http

给定一列字符串,我想从一个网站(如sciencedirect.com)查找每个字符串的搜索结果数。现有的答案对谷歌来说很有效

不幸的是,此解决方案从字符串创建搜索URL,例如,Google搜索包含单词example。我想使用的网站不这样做

例如,搜索返回URL


你知道我是如何用这种搜索引擎得到同样的结果的吗

单击搜索按钮时,您必须检查提交的表单。表单发送一个GET请求,其中包含搜索词,但随后您将被重定向到结果列表页面,并且结果页面的URL不再包含搜索词

我已使用此URL成功搜索语料库:

http://www.sciencedirect.com/science?_ob=QuickSearchURL&_method=submitForm&_acct=C000228598&_origin=home&_zone=qSearch&md5=61ce8901b141d527683913a240486ac4&qs_all=corpus
请注意,您需要做的是

下载起始页 从搜索表单中提取隐藏字段 从隐藏字段组合搜索URL 将您的搜索词添加到qs_all字段中的搜索URL 使用搜索URL发送GET请求 跟随重定向 除了qs_,此URL中的所有其他字段都作为隐藏字段来自表单。 这是相应表单的来源,因为我在发送语料库搜索请求之前下载了它:

<form name="qkSrch" method="get" target="_top" action="/science" style="margin:0px;">
<input type="hidden" name="_ob" value="QuickSearchURL">
<input type="hidden" name="_method" value="submitForm">
<input type="hidden" name="_acct" value="C000228598">
<input type="hidden" name="_origin" value="home">
<input type="hidden" name="_zone" value="qSearch">
<input type="hidden" name="md5" value="61ce8901b141d527683913a240486ac4">

<table border="0" width="100%" cellpadding="0" cellspacing="0" style="margin: 0;">
<tbody><tr valign="middle">

<!-- Code related for toggling labels -->

   <td align="right"><label for="qs_all" id="fieldLabel">&nbsp;&nbsp;&nbsp;&nbsp;All fields</label></td>
   <td align="left"><input class="textbox qsinput xpstyle" type="text" name="qs_all" id="qs_all" value="" size="30" maxlength="450" title="For example: heart attack AND behavior?" tabindex="1"></td>



   <td align="right"><label for="qs_author">&nbsp;&nbsp;&nbsp;&nbsp;Author</label></td>
   <td align="left" colspan="5"><input class="textbox qsinput xpstyle" type="text" name="qs_author" id="qs_author" value="" size="33" maxlength="450" title="e.g. J S Smith or John Smith or Smith JS" tabindex="2" style="_width:100%"></td>
   <td nowrap="nowrap">

   </td><td></td><td></td>
   <td align="right" nowrap="nowrap" width="90%" valign="middle">
   <a href="/science?_ob=MiamiSearchURL&amp;_method=requestForm&amp;_btn=Y&amp;_acct=C000228598&amp;_version=1&amp;_urlVersion=1&amp;_userid=10&amp;md5=18a1082f74248d90d465ee65804fd7db" style="vertical-align:bottom;font-size:0.92em;">Advanced search</a>
   </td>
</tr>
<tr>

   <td align="right"><label for="qs_title">&nbsp;&nbsp;&nbsp;&nbsp;Journal/Book&nbsp;title</label></td>
   <td align="left"><input class="textbox qsinput xpstyle" type="text" id="qs_title" name="qs_title" value="" size="30" maxlength="450" title="For example: journal of molecular biology" tabindex="3"></td>

   <td align="right" class="toggleQukSrch2"><label for="qs_vol" id="volField">&nbsp;&nbsp;&nbsp;&nbsp;Volume</label></td>
   <td align="left" class="toggleQukSrch"><input class="textbox qsinput xpstyle" type="text" name="qs_vol" id="qs_vol" value="" size="3" maxlength="10" style="width:30px;" tabindex="4"></td>
   <td align="right" class="toggleQukSrch2"><label for="qs_issue" id="issueField">&nbsp;&nbsp;Issue</label></td>
   <td align="left" class="toggleQukSrch"><input class="textbox qsinput xpstyle" type="text" name="qs_issue" id="qs_issue" value="" size="3" maxlength="10" style="width:30px" tabindex="5"></td>
   <td align="right" class="toggleQukSrch2"><label for="qs_pages" id="pageField">&nbsp;&nbsp;Page</label></td>
   <td align="right" class="toggleQukSrch"><input class="textbox qsinput xpstyle" type="text" name="qs_pages" id="qs_pages" value="" size="3" maxlength="10" title="For example: 14-27" style="width:30px" tabindex="6"></td>

   <td align="right" nowrap="nowrap">
   <input class="button" id="submit_search" type="Submit" alt="Submit Quick Search" title="Submit Quick Search" value="Search ScienceDirect" tabindex="8" name="sdSearch">
   </td> 



 <td align="right" nowrap="nowrap" colspan="8" valign="bottom">
      <a class="icon_qmarkHelpsci_dir" href="/science?_ob=HelpURL&amp;_file=qs_tips.htm&amp;_acct=C000228598&amp;_version=1&amp;_urlVersion=0&amp;_userid=10&amp;md5=2bd779305b31602341744eaa786e2f0a" target="sdhelp" onmouseover="window.status='Help is Available';return true" onmouseout="window.status='';return true" onclick="var helpWin;helpWin=window.open('/science?_ob=HelpURL&amp;_file=qs_tips.htm&amp;_acct=C000228598&amp;_version=1&amp;_urlVersion=0&amp;_userid=10&amp;md5=2bd779305b31602341744eaa786e2f0a','sdhelp','scrollbars=yes,resizable=yes,directories=no,toolbar=no,menubar=no,status=no,width=760,height=570');helpWin.focus();return false" tabindex="9" style="font-size:0.92em;padding-right:0;">Search tips</a>
   </td>
   </tr>
</tbody></table>
</form>
编辑 继续介绍如何从结果页面提取结果数

您的假设是正确的,您必须更改代码的其他部分,即提取结果数值的部分

让我们继续上一个例子。 从语料库中搜索时,您将在结果页面的源代码中找到这一行:

<input type="hidden" name="TOTAL_PAGES" value="2836">

你要提取2836。因此,您将搜索类似“谢谢”的内容。我很难将代码适应新网站,我不完全了解Excel代码中的Google结果数量在做什么。我已经更改了搜索url,但我假设代码的其他部分需要更改编辑答案,详细说明了这一点当我查看结果页的源时,我找不到从何处以及如何提取此内容?抱歉,我现在找到了,但是我注意到总页数是页数,而不是结果数,即一个小得多的数字。你真的很聪明!总页数不是所有搜索结果的数目。现在,你认为如何从页数中计算出结果的数量?提示:检查页面大小,即每页的结果数。我猜是50英镑。扰流板提示:将页面大小与总页面数相乘,在这种情况下,50*2836=141800难道你不能从API中获取此信息而不是刮取吗?