来自Excel的搜索结果数量
问题描述:
给出一串字符串,我想从每个字符串的网站(例如sciencedirect.com)中查找搜索结果的数量。现有的答案Number of Google Results from Excel适用于Google。来自Excel的搜索结果数量
不幸的是这种解决方案创建一个从字符串即谷歌搜索例如搜索URL中包含单词例子。我想使用的网站不这样做。
任何想法,我怎么achived相同的结果与这种类型的搜索引擎。
答
当您点击搜索按钮时,您必须检查您提交的表单。表单发送一个包含搜索条件的GET请求,但随后您将被重定向到结果列表页面,并且结果页面的URL不再包含搜索条件。
我已经成功地搜索“文集”这个URL:
http://www.sciencedirect.com/science?_ob=QuickSearchURL&_method=submitForm&_acct=C000228598&_origin=home&_zone=qSearch&md5=61ce8901b141d527683913a240486ac4&qs_all=corpus
需要注意的是你必须做的就是
- 下载起始页http://www.sciencedirect.com/
- 提取隐藏字段从搜索表单
- 从隐藏字段中汇编搜索URL
- 搜索字词与搜索URL
- 发送GET请求添加到搜索URL中
qs_all
领域 - 后续重定向
除了qs_all
在这个网址的所有其他领域来自于形式为隐藏领域。 这是相应形式的来源,因为我下载了它(发送“文集”的搜索请求之前。):
<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"> 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"> 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&_method=requestForm&_btn=Y&_acct=C000228598&_version=1&_urlVersion=1&_userid=10&md5=18a1082f74248d90d465ee65804fd7db" style="vertical-align:bottom;font-size:0.92em;">Advanced search</a>
</td>
</tr>
<tr>
<td align="right"><label for="qs_title"> Journal/Book 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"> 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"> 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"> 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&_file=qs_tips.htm&_acct=C000228598&_version=1&_urlVersion=0&_userid=10&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&_file=qs_tips.htm&_acct=C000228598&_version=1&_urlVersion=0&_userid=10&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因此,你将寻找类似<input type="hidden" name="TOTAL_PAGES" value="
并获得subequent值在结束报价之前。
我不会告诉你如何在VBA中编写代码,但它是基本的字符串操作,所以我希望你能处理它。
难道你不能从API获取这些信息而不是抓取? HTTP:// WWW。developer.sciverse.com/ – JimmyPena