使用查看页面源代码时缺少 Html [英] Html missing when using View page source

查看:52
本文介绍了使用查看页面源代码时缺少 Html的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从页面中提取所有图像.我已经使用 Mechanize Urllib 和 selenium 来提取 Html,但我想提取的部分从未存在.此外,当我查看页面源代码时,我无法查看我想要提取的部分.而不是我想提取的描述是这样的:

 

但是如果我尝试使用检查元素选项查看它,它就在那里.有没有一种简单的方法可以在没有任何 Java 知识的情况下弄清楚这个脚本的作用?所以我可以绕过它.或者有没有办法在python 2.7中使用selenium获得等效的inspect元素?无论如何,查看页面源代码和检查元素之间有什么区别?

解决方案

可能您正在尝试获取使用客户端脚本创建的元素.我不认为当您只发送 GET/POST 请求时 javascript 元素会运行(这就是我假设您所说的查看源代码"的意思).

Im trying to extract all the images from a page. I have used Mechanize Urllib and selenium to extract the Html but the part i want to extract is never there. Also when i view the page source im not able to view the part i want to extract. Instead of the Description i want to extract there is this:

 <div class="loading32"></div>
 </div>

 </div>
 </div>

But if i try to view it using the inspect element option its there. Is there a easy way to figure out what this script does without any java knowledge? So i can bypass it. or is there a way to get an equivalent of inspect element using selenium in python 2.7? What is the difference between View page source and inspect element anyway?

解决方案

Possibly you're trying to get elements that are created with a client sided script. I don't think javascript elements run when you just send a GET/POST request (which is what I'm assuming you mean by "view source").

这篇关于使用查看页面源代码时缺少 Html的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
Java开发最新文章
热门教程
热门工具
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆