当前位置: 首页>>代码示例>>Python>>正文


Python Node.properties[key]方法代码示例

本文整理汇总了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))
开发者ID:ShrutiGanesh18,项目名称:Scraper,代码行数:55,代码来源:ZalandoCrawler.py

示例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']
开发者ID:jasonzou,项目名称:bibliometric,代码行数:18,代码来源:PublicationLoad.py


注:本文中的py2neo.Node.properties[key]方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。