请问ajax后面的路径怎么拼接两个调用的参数啊加后缀,如下
我下面这种是错误的,请问该怎么进行拼接
window.location.href="<%= request.getContextPath() %>/sh/合并文件/"+text.id+""+text.name+".docx";
你可以使用字符串拼接的方式来拼接两个参数和后缀,例如:
window.location.href = "<%= request.getContextPath() %>/sh/合并文件/" + text.id + text.name + ".docx";
或者使用模板字符串的方式来拼接:
window.location.href = `${request.getContextPath()}/sh/合并文件/${text.id}${text.name}.docx`;
其中,模板字符串使用反引号(`)包裹字符串,可以在字符串中使用 ${} 来引用变量。
window.location.href = "<%= request.getContextPath() %>/sh/合并文件/test?id="+text.id+"&name="+text.name;
window.location.href="<%= request.getContextPath() %>/sh/合并文件/"+text.id+""+text.name+".docx?param1="+value1+"¶m2="+value2";
OK了,可以了,感谢各位大哥
for id in urls:
print("正在爬取景点:", id[1])
data_pre={
"arg":{
"channelType":2,
"collapseType":0,
"commentTagId":0,
"pageIndex":1,
"pageSize":10,
"poiId":id[0],
"sourceType":1,
"sortType":3,
"starType":0
},
"head":{
"cid":"09031027214030973865",
"ctok":"",
"cver":"1.0",
"lang":"01",
"sid":"8888",
"syscode":"09",
"auth":"",
"xsid":"",
"extension":[]
}
}
html=requests.post(postUrl,data=json.dumps(data_pre)).text
html=json.loads(html)
根据上述分析,在请求接口时需要相应参数,我们将之前获取的Request Payload参数拿出来,做成JSON文件,并将里面的“poiID”(景点ID)的值换成从景点数组中获取的变量,然后通过requests模块中的post函数,加入请求地址和参数,进行一次请求。并将获取到的数据通过JSON格式加载。