此函数通过AJAX加载HTML,并使用apiVersion: extensions/v1beta1
kind: Deployment
metadata:
annotations:
deployment.kubernetes.io/revision: "2"
sidecar.istio.io/rewriteAppHTTPProbers: "true"
creationTimestamp: null
generation: 1
labels:
app: nginx
name: nginx-deployment
selfLink: /apis/extensions/v1beta1/namespaces/development/deployments/nginx-deployment
spec:
progressDeadlineSeconds: 600
replicas: 1
revisionHistoryLimit: 10
selector:
matchLabels:
app: nginx
strategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
type: RollingUpdate
template:
metadata:
creationTimestamp: null
labels:
app: nginx
spec:
containers:
- image: nginx:1.7.9
imagePullPolicy: IfNotPresent
livenessProbe:
failureThreshold: 3
httpGet:
path: /
port: 80
scheme: HTTP
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 1
name: nginx
ports:
- containerPort: 80
name: http
protocol: TCP
resources: {}
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
terminationGracePeriodSeconds: 30
执行搜索/抓取。如果服务器名称是唯一的,它将很好地工作。但是,按照下面的示例,如果我搜索find()
,它将打印出server10
,因为它首先出现在HTML中。
有没有一种方法可以用来查找完全匹配和控制台日志server109 & amer
。尝试了各种方法但没有起作用。请提出或提供示例。
server10 & apj
someurl.html
function vm(vm_server) {
$.ajax({
url: 'http://someurl.com',
dataTpe: 'html',
type: 'GET',
success: function(data) {
var server_name = $(data).find("td:contains(" + vm_server + ")").text();
var location = $(data).find('td:contains("' + server_name + '")').next().text();
console.log(server_name)
console.log(location)
}
});
}