抓取链接应该是一件简单的事情,通常只需获取srca 标签的值即可。
我最近发现这个网站(https://sunteccity.com.sg/promotions),其中每个项目的a标签的href值都找不到,但重定向仍然有效。我正在尝试找出一种方法来获取项目及其相应的链接。我典型的 python selenium 代码看起来像这样
all_items = bot.find_elements_by_class_name('thumb-img')
for promo in all_items:
a = promo.find_elements_by_tag_name("a")
print("a[0]: ", a[0].get_attribute("href"))
Run Code Online (Sandbox Code Playgroud)
但是,我似乎无法检索任何href,onclick属性,我想知道这是否可能。我注意到我也无法在新选项卡中右键单击打开链接。
有什么方法可以获取所有这些项目的链接吗?
编辑: 有什么方法可以检索页面上项目的所有链接吗?
IE
https://sunteccity.com.sg/promotions/724
https://sunteccity.com.sg/promotions/731
https://sunteccity.com.sg/promotions/751
https://sunteccity.com.sg/promotions/752
https://sunteccity.com.sg/promotions/754
https://sunteccity.com.sg/promotions/280
...
Run Code Online (Sandbox Code Playgroud)
我没有找到太多关于这个的东西,使用方法和在脚本标签中声明一个函数有什么区别?
例子.vue
<script>
export default{
methods: {
testfunction1(){
...
}
},
mounted(){
this.testfunction1();
}
}
</script>
Run Code Online (Sandbox Code Playgroud)
相比
<script>
export default{
methods: {
...
},
mounted(){
testFunction1();
}
}
function testFunction1(){
...
}
</script>
Run Code Online (Sandbox Code Playgroud)
PS:如果它们都是合法的,它们的用例是什么?- 什么时候使用两者?
这是一个与下面这个问题非常相似的问题
以下是我检测图像粘贴事件的示例代码。
document.getElementById("imagePaste").onpaste = function (event) {
var items = (event.clipboardData || event.originalEvent.clipboardData).items;
console.log(JSON.stringify(items)); // will give you the mime types
for (index in items) {
var item = items[index];
if (item.kind === 'file') {
var blob = item.getAsFile();
const file = new File([blob], 'test', { type: blob.type })
console.log("file.size: ", file.size);
}
}
}
Run Code Online (Sandbox Code Playgroud)
控制台日志记录file.size返回的文件大小为 500kb,而上传完全相同的文件仅为 50kb(实际图像大小为 50kb)。为什么图像的大小增加了这么多?
提前致谢!