【发布时间】:2023-04-02 06:27:01
【问题描述】:
我想抓取来自webpage 的一些数据,即Cross Reference and Model Information
我有一个抓取所有其他数据表单页面的脚本。
但是由于所需的数据来自 id 的 Div 中的 Ajax 调用。
<div class="inner" style="overflow-x: hidden; overflow-y: scroll; height:300px;" id="xmodellist"><table>
<tbody><tr>
<th>Manufacturer</th>
<th>Model Number</th>
<th>Description</th>
</tr>
<tr>
<td>Amana</td>
<td><a href="/parts-for-amana-sxd26vw-p1315202w-w.html">SXD26VW</a></td>
<td>REF - SXS/I&W</td>
</tr></tbody></table>
</div>
来自view source的网页Ajax代码
$.ajax({
url: "/partmodellist.aspx?partid=" + partid + "&os=" + os.toString(),
success: function (data) {
if (data) {
$('#xmodel1').replaceWith(data);
$('#xmodellist').scroll(function () {
if (($('tr#trxrefloading').length > 0) && $('#xmodellist').scrollTop() + $('#xmodellist').innerHeight() >= $('#xmodellist')[0].scrollHeight) {
os = os + 1;
$.ajax({
url: "/partmodellist.aspx?partid=" + partid + "&os=" + os.toString(),
success: function (html) {
if (html) {
if (html.trim().length > 0)
{
$("tr#trxrefloading").before(html);
}
else
{
$('tr#trxrefloading').css("display", "none");
$('#xmodellist').unbind();
}
} else {
$('tr#trxrefloading').css("display", "none");
$('#xmodellist').unbind();
}
}
});
}
});
} else {
$('xmodel1').css("display", "none");
}
}
});
我想抓取该 div 中的所有信息。
我已附上我的existing code file. or this link
请提供建议,我该如何实现这一目标。
【问题讨论】:
-
仅供参考,它是 scrape(和 scraper、scraping、scraped)不是废品
标签: php ajax dom curl web-scraping