我正在使用 scrapy & splash 从启用了 javascript 的银行页面抓取促销交易。
https://www.dbs.com.sg/personal/product-promotion-list.page?pct=Cards#
我面临的问题是其中的分页是使用 javascript 完成的,因此链接采用这种格式:
<a href="#">1</a>
<a href="#">2</a>
<a href="#">3</a>
href 链接都隐藏在# 中。
当我进一步挖掘时,html 代码中的分页功能是:
<script type="text/javascript">
$(document).ready(function(){
productList();
});
$('.pagination').on("click","a",checkClass);
$('#filterSearch').on("click",searchTextChange);
$('form').submit(function(e){
e.preventDefault();
});
$("#Search").keyup(function(event){
if(event.keyCode == 13){
$("#filterSearch").click();
}
});
</script>
谁能帮我解决这个问题?任何帮助表示赞赏!谢谢。
最佳答案
通过单击每个分页(1、2 或 3),使用 POST 从服务器请求以下 URL:
https://www.dbs.com.sg/personal/product-promotion-list-child.page
使用以下发布的表单数据:
promotype=&start=1&pageNum=1&search=&type=promotion&pct=Cards
(第 1 页)
promotype=&start=2&pageNum=1&search=&type=promotion&pct=Cards
(第 2 页)
promotype=&start=3&pageNum=1&search=&type=promotion&pct=Cards
(第 3 页)
如果您直接传递正确的页码点击此 URL 会怎样?此请求返回包含您想要的促销列表的 HTML。
关于javascript - scrapy javascript 分页 href=#,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32707632/