tijiao
This commit is contained in:
90
getHtmlUrl.html
Normal file
90
getHtmlUrl.html
Normal file
@@ -0,0 +1,90 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>从链接中提取 a_id 并跳转</title>
|
||||
<style>
|
||||
#tmrUrl {
|
||||
width: 90%;
|
||||
height: 30px;
|
||||
font-size: 20px;
|
||||
border-radius: 2rpx;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<p>请输入期刊官网文章链接:</p>
|
||||
<input type="text" id="tmrUrl" placeholder="https://www.tmrjournals.com/article.html?J_num=2&a_id=3578">
|
||||
<button onclick="getHtml()" style="background-color: #20558a;color: #fff;">跳转</button>
|
||||
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
<script src="./js/jquery.min.js"></script>
|
||||
<script>
|
||||
var apiUrl = "/";
|
||||
// 从一个完整链接中提取某个参数
|
||||
function extractParamFromUrl(url, paramName) {
|
||||
try {
|
||||
const urlObj = new URL(url);
|
||||
return urlObj.searchParams.get(paramName);
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
function getHtml() {
|
||||
const url = document.getElementById('tmrUrl').value.trim();
|
||||
if (!url) {
|
||||
alert('请输入文章链接')
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const a_ID = extractParamFromUrl(url, 'a_id');
|
||||
if (!a_ID) {
|
||||
alert('链接中缺少 a_id 参数')
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
type: 'post', url: apiUrl + 'api/Article/getArticleDetail',
|
||||
data: {
|
||||
"article_id": a_ID
|
||||
},
|
||||
success: function (result) {
|
||||
console.log('result at line 39:', result)
|
||||
if (result.code == 0) {
|
||||
|
||||
if (result.data.articleInfo.html_type == 2) {
|
||||
|
||||
$.ajax({
|
||||
type: 'post', url: apiUrl + 'api/Article/getArticleDetailHtmlFor2',
|
||||
data: {
|
||||
"article_id": a_ID
|
||||
},
|
||||
success: function (result) {
|
||||
if (result.code == 0) {
|
||||
var article_id = result.data.mains[0].article_id;
|
||||
window.open(`https://submission.tmrjournals.com/GenerateCharts?id=${article_id}`, '_blank');
|
||||
}
|
||||
}
|
||||
})
|
||||
} else {
|
||||
alert('该文章不是自动化排版文章')
|
||||
}
|
||||
|
||||
} else {
|
||||
alert('获取不到该文章信息,请稍后重试')
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
</script>
|
||||
Reference in New Issue
Block a user