我正在尝试使用js计算标题长度,并且由于某种原因它不起作用。这是试图获得标题长度* 45
的代码public class Main {
public static void main(String[] args) throws Exception {
try {
HttpClient client = HttpClientBuilder.create().build();
HttpPost request = new HttpPost("http://localhost:8080/components");
request.setHeader("Accept", MediaType.APPLICATION_XML);
request.setHeader("Content-type", MediaType.MULTIPART_FORM_DATA);
HttpResponse response = client.execute(request);
if (response.getStatusLine().getStatusCode() != 200) {
throw new RuntimeException("Failed : HTTP error code : " + response.getStatusLine().getStatusCode());
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
感谢您的帮助。
由于
扬
答案 0 :(得分:1)
如果你使用JQuery那么下面的代码找到标题长度:
import matplotlib.pyplot as plt
indices = range(100) # already returns a list, no need to iterate again
values = # insert 1d vector here, what you seem to use is multi-dim
plt.plot(indices, values)
plt.show()
答案 1 :(得分:0)
您可以在检查长度之前检查它是否已定义:
Promise
答案 2 :(得分:0)
使用此..这应该有用。
document.getElementsByTagName('title')[0].innerText.length;