您可以使用 javascript 查找图像的 URL,然后将该信息传递到 Coldfusion 中吗?

发布于 2024-12-22 17:16:40 字数 769 浏览 1 评论 0原文

您可以使用 javascript 查找图像的 URL,然后将该信息传递到 Coldfusion 中,而不是在 CF 或 JS 中使用 regx 吗?

在我看来,firefly 可以很好地找到所有获取图像 URL 的内部网络选项卡,并且 DOM 理解什么是图像对象或图像链接。

我可以访问已经在其他地方排序的信息堆栈吗?

创建图像的代码类似于 e=new L(f||"//chart.googleapis.com/chart");和 可以在 http://www.google.com/finance?q 找到=纳斯达克:SQNM&fstype=ii

我们的目标是使用这些图表来快速参考 http://www.investingNideas.com

我的旧支持方法是 cfhttp 和两个正则表达式

脚本 = REMatchNoCase(']>[^<]', objGet.FileContent) />>; //获取脚本

Finance = REMatchNoCase(']+>.+?', objGet.FileContent) //gets divs

我正在研究 javascript 反射或 iframe 内部的反射。

谢谢

Can you use javascript to find the URL's of images and then pass that info into coldfusion and not use regx inside CF or JS?

it seems to me that firefly can find all the get image URL's inside net tab just fine and the DOM understands what is an image object or image link.

Can I access that stack of information already sorted someplace else.

The code that creates the images looks like e=new L(f||"//chart.googleapis.com/chart"); and
can be found at http://www.google.com/finance?q=NASDAQ:SQNM&fstype=ii.

The goal is to use these charts for a quick reference at http://www.investingNideas.com

My old stand bye methods are cfhttp and two regex

script = REMatchNoCase(']>[^<]', objGet.FileContent) /> //gets scripts

finance = REMatchNoCase(']+>.+?', objGet.FileContent) />//gets divs

I was looking into javascript reflection or reflection inside of iframe.

thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

北斗星光 2024-12-29 17:16:40

我已经测试过这个,它确实有效。希望我对“工作”的理解和你一样。这里涉及到一些技巧,因为您需要访问的图像是由浏览器中的 javascript 渲染生成的,因此服务器端屏幕抓取是不够的(除非事情变得非常复杂,而我不会去那里)。另外,事情很棘手,因为您需要加载的内容位于远程域 (www.google.com) 上,这意味着您在浏览器中访问该内容的方式受到限制(如果没有适当的方法,无法通过 Ajax 真正做到这一点)谷歌服务器上的 Access-Control-Allow-Origin 标头无法通过嵌入直接 iframe 来访问它,以防止跨域 DOM 操作。因此,我必须解决这两个限制。需要注意的是 - 我意识到你没有要求 jQuery,但老实说,它让这里的生活变得更加轻松,所以我继续使用它。所以这就是我如何让它工作:

index.cfm

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script>
$(function () {
        $("#googleFrame").load(function () { // bind to the load event, so we'll know that the embedded resources will all have finished rendering (including the images we're after)

                // this will simply include the images from google on the current page
                $("#rippedGoogleImages")
                   .html('') // remove the loading message
                   .append($(this).contents().find("img.goog-serverchart-image")); // pull the loaded images out of the frame

                // if you just want to see the URLs of those images:
                /* $(this).contents().find("img.goog-serverchart-image").each(function (){
                    console.log($(this).attr('src'));
                });
                */

        });
        $("#googleFrame").attr("src", "googleProxy.cfm"); // trickiness that will become clear below
});
</script>

<iframe id="googleFrame" style="display:none"></iframe><!-- hidden iframe -->

<h1>Finance Images</h1>

<div id="rippedGoogleImages">
Loading Images From Google...
</div>

以及允许我们绕过跨域限制的关键,一个在服务器上执行对 google 的直接请求的文件:googleProxy.cfm:

<cfhttp url="http://www.google.com/finance?q=NASDAQ:SQNM&fstype=ii">

<cfoutput>
#cfhttp.filecontent#
</cfoutput>
<!--- The next line injects the necessary base href to allow the resources (js, css, images, etc...) to resolve correctly when served from this new location --->
<cfhtmlhead text="<base href='http://www.google.com/finance/'>">

所有这些都在没有令人讨厌的服务器端屏幕的情况下完成抓取或正则表达式。

I've tested this, and it does work. Hopefully my understanding of "work" is the same as yours. There are a few tricks involved, because the images you need to access are produced by javascript rendering within the browser, so server-side screen-scraping would not suffice (unless things got really complicated, and I'm not going there). Also, things are tricky because the content you need loaded is on a remote domain (www.google.com) and that means there are restrictions on how you can access that content within the browser (can't really do this via Ajax without proper Access-Control-Allow-Origin headers on the google server; can't access this by embedding a direct iframe for similar restrictions preventing cross-domain DOM manipulation). So, I had to work around both of those limitations. One note - I realize you didn't ask for jQuery, but it honestly makes life so much easier here that I went ahead and used it. So here's how I got it working:

index.cfm

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script>
$(function () {
        $("#googleFrame").load(function () { // bind to the load event, so we'll know that the embedded resources will all have finished rendering (including the images we're after)

                // this will simply include the images from google on the current page
                $("#rippedGoogleImages")
                   .html('') // remove the loading message
                   .append($(this).contents().find("img.goog-serverchart-image")); // pull the loaded images out of the frame

                // if you just want to see the URLs of those images:
                /* $(this).contents().find("img.goog-serverchart-image").each(function (){
                    console.log($(this).attr('src'));
                });
                */

        });
        $("#googleFrame").attr("src", "googleProxy.cfm"); // trickiness that will become clear below
});
</script>

<iframe id="googleFrame" style="display:none"></iframe><!-- hidden iframe -->

<h1>Finance Images</h1>

<div id="rippedGoogleImages">
Loading Images From Google...
</div>

And the key that allows us to get around cross-domain restrictions, a file that performs the direct request to google on the server: googleProxy.cfm:

<cfhttp url="http://www.google.com/finance?q=NASDAQ:SQNM&fstype=ii">

<cfoutput>
#cfhttp.filecontent#
</cfoutput>
<!--- The next line injects the necessary base href to allow the resources (js, css, images, etc...) to resolve correctly when served from this new location --->
<cfhtmlhead text="<base href='http://www.google.com/finance/'>">

All accomplished without nasty server-side screen scraping or regular expressions.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文