[英]Can I scrape data from web pages when the data comes from JavaScript?
I'm not exactly sure how to phrase my question but I'll give it my best shot. 我不确定如何表达我的问题,但我会尽力而为。
If I load up a webpage, in the HTML it executes a JavaScript file. 如果我加载网页,则在HTML中执行一个JavaScript文件。 And if I view the page source I can see the source of that JavaScript (though it's not very well formatted and hard to understand).
而且,如果我查看页面源代码,则可以看到该JavaScript的源代码(尽管它的格式不是很好,而且很难理解)。
Is there a way to run the JavaScript from eg Python code, without going through the browser? 有没有一种方法可以通过Python代码运行JavaScript,而无需通过浏览器? ie if I wanted to access a particular function in that JavaScript, is there a clean way to call just that from a Python script, and read the results?
即,如果我想访问该JavaScript中的特定函数,是否有一种干净的方法可以从Python脚本中仅调用该函数并读取结果?
For example... a webpage displays a number that I want access to. 例如,一个网页显示一个我想访问的号码。 It's not in the page source because it's a result from a JavaScript call.
它不在页面源中,因为它是来自JavaScript调用的结果。 Is there a way to call that JavaScript from Python?
有没有办法从Python调用JavaScript?
If you want to scrape a page with javascript in it you've got at least two options: 如果您要抓取带有javascript的页面,则至少有两个选择:
Although your question isn't very clear. 虽然您的问题不是很清楚。 I'm guessing that you are trying to access the javascript console.
我猜您正在尝试访问JavaScript控制台。
In Google Chrome: 在谷歌浏览器中:
In Mozilla Firefox with Firebug installed: 在安装了Firebug的Mozilla Firefox中:
From the console you can execute javascript query's (calling functions, accessing variables etc.). 从控制台,您可以执行javascript查询(调用函数,访问变量等)。
I hope this answered your question properly. 我希望这能正确回答您的问题。
I think you are talking about Obfuscate js code 我认为您正在谈论的是模糊的js代码
You can always de-obfuscate them 您可以随时对它们进行模糊处理
There are lots of tools availaible 有很多可用的工具
Here is a addon of mozilla https://addons.mozilla.org/en-us/firefox/addon/javascript-deobfuscator/ 这是mozilla https://addons.mozilla.org/en-us/firefox/addon/javascript-deobfuscator/的附加组件
and an online tool http://jsbeautifier.org/ 和一个在线工具http://jsbeautifier.org/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.