我为Amazon编写了一个函数,在给定URL的情况下,它为我提供产品的标题、价格和评级。如果我给它一个字符串格式的URL,它会工作得很好。我想使用这个函数,比如说它叫做AmazonCrawler
,以便从网站上获取整个产品类别,而不仅仅是单个产品。我该怎么做
编辑:
下面是一个我想略过的示例页面:Amazon TV Category。如果我查看页面源代码,我会发现:
<script type='text/javascript'>var ue_t0=ue_t0||+new Date();</script>
<!-- sp:feature:cs-optimization -->
<meta http-equiv='x-dns-prefetch-control' content='on'>
<link rel="dns-prefetch" href="https://images-eu.ssl-images-amazon.com">
<link rel="dns-prefetch" href="https://m.media-amazon.com">
<link rel="dns-prefetch" href="https://completion.amazon.com">
<script type='text/javascript'>
window.ue_ihb = (window.ue_ihb || window.ueinit || 0) + 1;
if (window.ue_ihb === 1) {
我对在亚马逊网站上查找所有智能电视的URL感兴趣。有没有一种自动化的方法
如果您使用google inspector,您将在指向所需URL的图像上找到href。例如,您找到的第一个Samsum TV的href位于以下Xpath处:
从这里开始,您需要找到一种方法来概括搜索
您需要一个选择器,该选择器以src以.jpg结尾的所有img为目标,但还需要排除几个其他早期匹配项。使用
:not
和前面的.a-row
可以做到这一点。最后,您需要使用set来清除唯一项相关问题 更多 >
编程相关推荐