如何获取.asp页面下一页的URL?

时间:2018-04-20 19:58:44

标签: javascript asp.net url web-scraping

我正试图通过此链接抓取数据:https://thereserve2.apx.com/myModule/rpt/myrpt.asp?r=112

我可以获得第一页,但是当我到达下一页(使用页面底部的“下一步”按钮)时,下一页的网址是通用的:https://thereserve2.apx.com/myModule/rpt/myrpt.asp

如何在自动抓取工作中获得更具体的URL?

感谢。

1 个答案:

答案 0 :(得分:1)

Check below HTML and JS code that submits the asp page and go to needed page, "next" button submit the form as you see in below JS an X999whichpage is the next page, you need to do the same submit the form with the needed page number.

function submitform2(X999sort, X999field, X999paging, X999whichpage, X999csv, X999action, X999actionfield) {
  document.xxxx2.X999csv.value = X999csv;
  document.xxxx2.X999action.value = X999action;
  document.xxxx2.X999actionfield.value = X999actionfield;
  document.xxxx2.X999sort.value = X999sort;
  document.xxxx2.X999field.value = X999field;
  document.xxxx2.X999paging.value = X999paging;
  document.xxxx2.X999whichpage.value = X999whichpage;
  document.xxxx2.submit();
}
<form id="xxxx2" name="xxxx2" action="https://thereserve2.apx.com/myModule/rpt/myrpt.asp?r=112" method="POST">
  <input type="hidden" name="X999myquery" value="">
  <input type="hidden" name="X999tablenumber" value="2">
  <input type="hidden" name="X999csv" value="">
  <input type="hidden" name="X999sort" value="">
  <input type="hidden" name="X999action" value="">
  <input type="hidden" name="X999actionfield" value="">
  <input type="hidden" name="X999field" value="On">
  <input type="hidden" name="X999paging" value="">
  <input type="hidden" name="X999whichpage" value="3">
</form>

Enter Page Number:<input type="text" id="whichpage" value="2"> 
<button onclick="javascript:submitform2('','','On',document.getElementById('whichpage').value,'','','')">Move to Page</button>

Another solution without JS

<form id="xxxx2" name="xxxx2" action="https://thereserve2.apx.com/myModule/rpt/myrpt.asp?r=112" method="POST">
<input type = "hidden" name = "X999tablenumber" value = "2" />
<input type = "hidden" name = "X999csv" value = "" />
<input type = "hidden" name = "X999sort" value = "" />
<input type = "hidden" name = "X999action" value = "" />
<input type = "hidden" name = "X999actionfield" value = "" />
<input type = "hidden" name = "X999field" value = "" />
<input type = "hidden" name = "X999paging" value = "On" />
<input type = "text" name = "X999whichpage" value = "3" />

<input type="submit" value="Go To Page" />
</form>