本文整理汇总了Python中py2neo.Node.properties[key]方法的典型用法代码示例。如果您正苦于以下问题:Python Node.properties[key]方法的具体用法?Python Node.properties[key]怎么用?Python Node.properties[key]使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类py2neo.Node
的用法示例。
在下文中一共展示了Node.properties[key]方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_product_details
# 需要导入模块: from py2neo import Node [as 别名]
# 或者: from py2neo.Node import properties[key] [as 别名]
def get_product_details(self,product_url,gender):
print self.count
self.count = self.count + 1
try:
product_html = requests.get(product_url).content
except Exception as e:
product_html = requests.get(product_url).content
product_soup = BeautifulSoup(product_html,"lxml")
product_image = product_soup.find("img","articleMedia_imagePlaceholder")
article_span = product_soup.find("span","sku")
product_name = product_soup.find("h1","productName noBg")
brand = product_name.contents[1]
product_info = dict()
product_info["article_number"] = article_span.string
product_info["brand"] = brand.string
product_info["gender"] = gender
ul = article_span.parent.parent
self.logger.write("%s being explored" %(article_span.string)+"\n")
for li in ul.contents:
if li.string is not None and str(type(li))=="<class 'bs4.element.Tag'>":
var = li.get('class')[0]
if(len(li.string.split(":")) > 1 ):
product_info[li['class'][0]] = li.string.split(":")[1].encode("ascii","ignore")
n = Node(gender,"Zalando","Product")
for key in product_info:
n.properties[key] = product_info[key]
while (product_image is not None):
url = product_image['src']
file_name = url.split('/')[-1]
folder_name = file_name.split('@')[0]
if os.path.exists(folder_name):
break
os.makedirs(folder_name)
os.chdir(folder_name)
url = url.replace("detail","large")
try:
r = requests.get(url)
except Exception as e:
r = requests.get(url)
open(file_name,"w").write(r.content)
os.chdir("..")
n["file_system_url"] = "Zalando/"+folder_name
n["image_url"] = url
product_image = product_image.nextSibling.nextSibling
try:
self.zalando_graph.create(n)
except Exception as e:
self.logger.write("Node %s already exists" %(article_span.string))
示例2: save_publications_list
# 需要导入模块: from py2neo import Node [as 别名]
# 或者: from py2neo.Node import properties[key] [as 别名]
def save_publications_list(publications):
"""
Method to save all the publications to neo4j database
"""
graph = Graph()
for publication in publications:
publication_node = Node("Publication")
for key in publication:
if key not in ['_id', 'authorsSearched', 'identifiers', 'rank', 'work-citation-type']:
publication_node.properties[key] = publication[key]
graph.create(publication_node)
print 'Inserted Publication: ' + publication['doi']