代码拉取完成,页面将自动刷新
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
import sys
import os
path = os.getcwd()
path = os.path.dirname(path)
sys.path.append(path)
import time
import datetime
import requests
import json
#url中的*.*.*.*指的是部署neo4j查询服务的服务器地址(跟neo4j数据库的地址相同)
def mode_get_1():
""" get """
url = "http://*.*.*.*:80/graph_search?subject=张伯苓&search_type=1"
response = requests.request("GET", url)
resp = response.text
print(json.loads(resp))
def mode_post_1():
""" post """
url = "http://*.*.*.*:80/graph_search"
payload = json.dumps({"subject": "张伯苓", "search_type": 1})
headers = {'Content-Type': 'application/json'}
response = requests.request("POST", url, headers=headers, data = payload)
print(response.text)
def mode_get_2():
""" get """
url = "http://*.*.*.*:80/graph_search?subject=张伯苓&relation=民族&search_type=2"
response = requests.request("GET", url)
resp = response.text
print(json.loads(resp))
def mode_post_2():
""" post """
url = "http://*.*.*.*:80/graph_search"
payload = json.dumps({"subject": "张伯苓", "relation":"民族","search_type": 2})
headers = {'Content-Type': 'application/json'}
response = requests.request("POST", url, headers=headers, data = payload)
print(response.text)
def mode_get_3():
""" get """
url = "http://*.*.*.*:80/graph_search?subject=张伯苓&relation=职业&object=教育家&search_type=3"
response = requests.request("GET", url)
resp = response.text
print(json.loads(resp))
def mode_post_3():
""" post """
url = "http://*.*.*.*:80/graph_search"
payload = json.dumps({"subject": "张伯苓", "relation":"职业", "object":"教育家", "search_type": 3})
headers = {'Content-Type': 'application/json'}
response = requests.request("POST", url, headers=headers, data = payload)
print(response.text)
def mode_get_4():
""" get """
url = "http://*.*.*.*:80/graph_search?subject=张伯苓&object=天津&search_type=4"
response = requests.request("GET", url)
resp = response.text
print(json.loads(resp))
def mode_post_4():
""" post """
url = "http://*.*.*.*:80/graph_search"
payload = json.dumps({"subject": "张伯苓", "object":"天津", "search_type": 4})
headers = {'Content-Type': 'application/json'}
response = requests.request("POST", url, headers=headers, data = payload)
print(response.text)
if __name__ == '__main__':
start = time.time()
#mode_get_4()
mode_post_4()
end = time.time()
delta = end - start
print("Finished time is {}".format(datetime.timedelta(seconds=delta)))
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。