使用curl从一个网页转到另一个涉及javascript的网页

发布于 2024-08-17 10:56:58 字数 173 浏览 3 评论 0原文

我有webpage1.html,它有一个超链接,其href =“some/javascript/function/outputLink()”

现在,使用curl(或php中的任何其他方法)如何推断出超链接(http://格式) javascript function() 以便我可以转到下一页。

谢谢

I have webpage1.html which has a hyperlink whose href="some/javascript/function/outputLink()"

Now, using curl (or any other method in php) how do I deduce the hyperlink (of http:// format) from the javascript function() so that I can go to next page.

Thanks

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

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

发布评论

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

评论(2

彩扇题诗 2024-08-24 10:56:58

你必须抓取 JavaScript。找出该函数的位置并查看它使用的 URL。

有时,同一页面上的链接会省略 http://,因此这不是一个好的搜索参考。

此时,唯一有价值的事情就是自己尝试理解 JavaScript 代码,一旦找到链接,您就可以使用 正则表达式 通过 PHP 以编程方式过滤结果。

preg_match("/url + \'\/apples.html/g", "blah blah var javaScriptVar= url + '/apples.html';", $matches);

You'd have to scrape the JavaScript. Figure out where the function is and see what URL it's using.

Sometimes http:// is omitted for links that are on the same page, so that won't be a good search reference.

At this point the only valuable thing to do is to try and understand the JavaScript code yourself, and once you find the link you could use regex to filter the result programmatically with PHP.

preg_match("/url + \'\/apples.html/g", "blah blah var javaScriptVar= url + '/apples.html';", $matches);
很酷不放纵 2024-08-24 10:56:58

没有直接的方法。很少有库可以完美地满足您的要求,甚至为零。我认为 http://www.dapper.net/ 很接近你想要的。我不确定这是否是理想的解决方案。 Dapper.net 将帮助您解析文本和链接,并且可能还会处理 javascript。

There is no straight forward way. There are very few to zero libraries which can perfectly do what you require. I think http://www.dapper.net/ is something close to what you want. I am not sure if its the ideal solution. Dapper.net will help you parse text and links and would probably also handle javascript.

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