在javascript或c#中从HTML源查找重定向URL - javascript

我尝试检查某些网站的html,但是内容上存在重定向。
如何从HTML获取重定向的URL?

注意:使用这些代码,我们可以重定向页面:

<meta http-equiv="refresh" content="0; url=http://example.com/" />

要么

<script type="text/javascript">
window.location.href = "http://example.com"
</script>

要么

<link rel="canonical" href="http://www.example.com/product.php?item=swedish-fish"/>

要么

<meta http-equiv="Refresh" content="3; url=http://example.com/alternate_url.html">

要么

<noscript>
<meta http-equiv="refresh" content="3" />
</noscript>

....

参考方案

id属性添加到meta标签,如下所示:

<meta id="idRefresh" http-equiv="Refresh" content="5555555; url=http://example.com/alternate_url.html"/>

然后使用纯正的Javascript

var e = document.querySelector("meta[id='idRefresh']");
var content = e && e.getAttribute("content");
var result = content && content.replace("5555555; url=","");

console.log(result);
//results in
//http://example.com/alternate_url.html

注意:如果更改刷新时间(在我的测试示例中为5555555),则还需要在replace(..)方法中进行更改

Mongo汇总 - javascript

我的收藏中有以下文件{ "_id": ObjectId("54490b8104f7142f22ecc97f"), "title": "Sample1", "slug": "samplenews", "cat": …

html | textarea中的额外标签 - javascript

我正在尝试将Markdown从数据库加载到textarea:<textarea class="wmd-input" id="wmd-input" name="question" required="required"> <?php echo '**Th…

如何用jQuery隐藏模态? - javascript

纽扣<button type="button" class="btn" onclick="CountClass()" runat="server" data-toggle="modal" data-target="#inlineForm1�…

html onClick打开url存储在php变量中 - javascript

以下是我的代码,正在获取Uncaught SyntaxError: Unexpected token },但是我的代码中没有看到任何}。 window.open期望用引号引起来的url,我尝试了单引号和双引号的不同组合,但不起作用并且也无法在echo中转义双引号。请帮助谢谢..<?php $a = "https://www.google.co…

Javascript-从当前网址中删除查询字符串 - javascript

单击提交按钮后,我需要从网址中删除查询字符串值。我可以用jQuery做到这一点吗?当前网址:siteUrl/page.php?key=value 页面提交后:siteUrl/page.php 实际上,我已经从另一个带有查询字符串的页面着陆到当前页面。我需要在页面首次加载时查询字符串值以预填充一些详细信息。但是,一旦我提交了表格,我就需要删除查询字符串值。我已…