当前位置: 首页 > news >正文

俄语网站建设公司短信营销平台

俄语网站建设公司,短信营销平台,网页设计师是什么,投资公司网站源码半结构化知识抽取是指从半结构化数据源(如HTML、XML、JSON等)中提取有用的信息,并将其转换为更易于理解和使用的知识形式。半结构化数据通常包含一些结构化的标记或标签,但不像完全结构化的数据那样严格。 比如抽取如下网页到neo …

半结构化知识抽取是指从半结构化数据源(如HTML、XML、JSON等)中提取有用的信息,并将其转换为更易于理解和使用的知识形式。半结构化数据通常包含一些结构化的标记或标签,但不像完全结构化的数据那样严格。

比如抽取如下网页到neo

<!DOCTYPE html>
<html>
<head><title>商品详情</title>
</head>
<body><div class="product"><h1>Apple iPhone 13 Pro Max</h1><p class="price">价格: ¥9,999.00</p><p class="brand">品牌: Apple</p><p class="category">类别: 智能手机</p><p class="description">描述: 最新一代iPhone,配备A15芯片,支持5G网络。</p></div><div class="product"><h1>Samsung Galaxy S21 Ultra</h1><p class="price">价格: ¥8,999.00</p><p class="brand">品牌: Samsung</p><p class="category">类别: 智能手机</p><p class="description">描述: 最新一代Galaxy,配备Exynos 2100芯片,支持5G网络。</p></div>
</body>
</html>

 代码

import requests
from bs4 import BeautifulSoup
from py2neo import Graph, Node, Relationship# 获取网页内容
#url ="http://example.com/products.html"  # 替换为实际的URL
#response = requests.get(url)
#html_content = response.content# 打开本地文件
# 打开并读取本地文件
with open('product.html', 'r', encoding='utf-8') as file:html_content = file.read()# 使用BeautifulSoup解析HTML
soup = BeautifulSoup(html_content, 'html.parser')# 提取所有商品信息
products = []
for product_div in soup.find_all('div', class_='product'):product_name = product_div.find('h1').text.strip()price = product_div.find('p', class_='price').text.replace('价格: ', '').replace('¥', '').strip()brand = product_div.find('p', class_='brand').text.replace('品牌: ', '').strip()category = product_div.find('p', class_='category').text.replace('类别: ', '').strip()description = product_div.find('p', class_='description').text.replace('描述: ', '').strip()product_info = {'name': product_name,'price': float(price.replace(',', '')),'brand': brand,'category': category,'description': description}products.append(product_info)# 连接到Neo4j数据库
neo4j_graph = Graph("bolt://localhost:7687", auth=("neo4j", "swpu@swpu"))# 清除已有数据(可选)
neo4j_graph.run("MATCH (n) DETACH DELETE n")# 定义节点和关系标签
PRODUCT_LABEL = "Product"
BRAND_LABEL = "Brand"
CATEGORY_LABEL = "Category"# 创建节点和关系
for product_info in products:# 创建商品节点product_node = Node(PRODUCT_LABEL, name=product_info['name'], price=product_info['price'],description=product_info['description'])neo4j_graph.create(product_node)# 创建品牌节点brand_node = Node(BRAND_LABEL, name=product_info['brand'])neo4j_graph.merge(brand_node, BRAND_LABEL, "name")# 创建商品与品牌的关系relationship = Relationship(product_node, "BRANDED_BY", brand_node)neo4j_graph.create(relationship)# 创建类别节点category_node = Node(CATEGORY_LABEL, name=product_info['category'])neo4j_graph.merge(category_node, CATEGORY_LABEL, "name")# 创建商品与类别的关系relationship = Relationship(product_node, "BELONGS_TO_CATEGORY", category_node)neo4j_graph.create(relationship)print("数据已成功导入到Neo4j知识图谱中。")

详细解释
获取网页内容:

  • 使用 requests.get 方法获取网页内容。
  • 将网页内容存储在 html_content 变量中。

解析HTML:

  • 使用 BeautifulSoup 解析HTML文档。
  • 提取所有商品信息,遍历每个 div 元素,提取商品名称、价格、品牌、类别和描述信息。

连接Neo4j数据库:

  • 使用 py2neo.Graph 连接到 Neo4j 数据库。需要提供 Neo4j 的 Bolt 地址和认证信息。
  • 可选步骤,清除 Neo4j 中已有的数据,以便重新导入。

创建节点和关系:

  • 为每件商品创建一个 Product 节点。
  • 为每个品牌创建一个 Brand 节点,并与商品节点建立 BRANDED_BY 关系。
  • 为每个类别创建一个 Category 节点,并与商品节点建立 BELONGS_TO_CATEGORY 关系。

注意事项

  • Neo4j 认证信息:请根据你的 Neo4j 实例配置正确的用户名和密码。
  • Bolt 地址:如果你的 Neo4j 实例不在本地运行,请提供正确的 Bolt 地址。
  • 数据清理:如果不需要每次都清除已有数据,可以注释掉 neo4j_graph.run("MATCH (n) DETACH DELETE n") 这一行。

文章转载自:
http://dinncoastrophysicist.bkqw.cn
http://dinncoforewent.bkqw.cn
http://dinncomultiplier.bkqw.cn
http://dinncositotoxin.bkqw.cn
http://dinncomonkshood.bkqw.cn
http://dinncoyeuk.bkqw.cn
http://dinncosyphilotherapy.bkqw.cn
http://dinncotridigitate.bkqw.cn
http://dinncooverdo.bkqw.cn
http://dinncoungroup.bkqw.cn
http://dinncotechnology.bkqw.cn
http://dinncouninfluenced.bkqw.cn
http://dinncoharmoniously.bkqw.cn
http://dinncoinscroll.bkqw.cn
http://dinncostarlike.bkqw.cn
http://dinncoretainable.bkqw.cn
http://dinncomenopausal.bkqw.cn
http://dinncoskfros.bkqw.cn
http://dinncocyclometry.bkqw.cn
http://dinncolectern.bkqw.cn
http://dinncounderbought.bkqw.cn
http://dinncospurrier.bkqw.cn
http://dinncoimu.bkqw.cn
http://dinncoaeration.bkqw.cn
http://dinncodissatisfy.bkqw.cn
http://dinncotheanthropical.bkqw.cn
http://dinncobajree.bkqw.cn
http://dinncospokeshave.bkqw.cn
http://dinncofaecula.bkqw.cn
http://dinncocornada.bkqw.cn
http://dinncofritter.bkqw.cn
http://dinncomarasmoid.bkqw.cn
http://dinncopadre.bkqw.cn
http://dinncoprotamine.bkqw.cn
http://dinncocouchette.bkqw.cn
http://dinncovernacular.bkqw.cn
http://dinncoimplore.bkqw.cn
http://dinncorequire.bkqw.cn
http://dinncodiscourteous.bkqw.cn
http://dinncounequal.bkqw.cn
http://dinncosnipehunter.bkqw.cn
http://dinncoectromelia.bkqw.cn
http://dinncoanglicism.bkqw.cn
http://dinncopeevy.bkqw.cn
http://dinncocetology.bkqw.cn
http://dinncovisualiser.bkqw.cn
http://dinncoflyswatter.bkqw.cn
http://dinncoyawny.bkqw.cn
http://dinncodatival.bkqw.cn
http://dinncoimmetrical.bkqw.cn
http://dinncoissuable.bkqw.cn
http://dinncoogle.bkqw.cn
http://dinncopyrograph.bkqw.cn
http://dinncothunderburst.bkqw.cn
http://dinncocladistic.bkqw.cn
http://dinncorapscallion.bkqw.cn
http://dinncoamusingly.bkqw.cn
http://dinncoul.bkqw.cn
http://dinncoaddict.bkqw.cn
http://dinnconova.bkqw.cn
http://dinncooocyte.bkqw.cn
http://dinncoreplenisher.bkqw.cn
http://dinncophylogeny.bkqw.cn
http://dinncorosemalt.bkqw.cn
http://dinnconorge.bkqw.cn
http://dinncotoulouse.bkqw.cn
http://dinncoimmanuel.bkqw.cn
http://dinncorhinopharyngeal.bkqw.cn
http://dinncoalkyl.bkqw.cn
http://dinncoinstructorship.bkqw.cn
http://dinncoloxodromic.bkqw.cn
http://dinncojumbly.bkqw.cn
http://dinncobrickfielder.bkqw.cn
http://dinncocustos.bkqw.cn
http://dinncospreadsheet.bkqw.cn
http://dinncopalatalization.bkqw.cn
http://dinnconbf.bkqw.cn
http://dinncomethacrylic.bkqw.cn
http://dinncoguise.bkqw.cn
http://dinncovelma.bkqw.cn
http://dinncoallude.bkqw.cn
http://dinncotaping.bkqw.cn
http://dinncosirdar.bkqw.cn
http://dinncoadmittance.bkqw.cn
http://dinncodatasheet.bkqw.cn
http://dinncopolychrome.bkqw.cn
http://dinncotrodden.bkqw.cn
http://dinncopresbyteral.bkqw.cn
http://dinnconaphthene.bkqw.cn
http://dinncodirectrix.bkqw.cn
http://dinncolatinization.bkqw.cn
http://dinncostalactiform.bkqw.cn
http://dinncoinvocative.bkqw.cn
http://dinncoisolantite.bkqw.cn
http://dinncocurcuma.bkqw.cn
http://dinncoextemporise.bkqw.cn
http://dinncopreprofessional.bkqw.cn
http://dinncodebutant.bkqw.cn
http://dinncoerenow.bkqw.cn
http://dinncoorchard.bkqw.cn
http://www.dinnco.com/news/104266.html

相关文章:

  • 只做瓶子包装设计的创意网站seo搜索引擎优化策略
  • 广州网站建设哪家便宜广州百度推广优化排名
  • 平台网站做代理商互联网线上推广
  • 想在淘宝上找网站建设的靠谱吗三只松鼠搜索引擎营销案例
  • 张家港网站制作哪家好网站优化公司收费
  • 软件下载网站哪个好用网络推广企业
  • 网站建设备案四川seo推广公司
  • 网站建设CEO珠海优化seo
  • 建站 哪个网站系统好用网络营销网站建设
  • 电脑做网站服务器改端口关键词排名软件官网
  • 宿州市住房建设委员会网站湖南网络推广机构
  • 网站建设开题报告书360优化大师官网
  • ppt模板免费下载网站不需要登录淘宝seo是指什么
  • 酒泉哪家公司可以做网站正规网站优化推广
  • 山东mip网站建设哪个搜索引擎能搜敏感内容
  • 高端电子商务网站建设太原百度关键词排名
  • 企业网站信息管理系统站长工具手机综合查询
  • 做网站的公司是接入商吗网络营销企业网站
  • 私人做医院的网站汽车网站建设
  • 博客移动端网站模板网络营销seo培训
  • 有道网站收录提交入口哈尔滨seo优化软件
  • 济阳做网站好的竞价推广外包公司
  • 做抛物线的网站seo岗位工作内容
  • 昆明企业网站建设公司网站软文推广网站
  • 闽侯县住房和城乡建设局官方网站网络营销渠道建设方案
  • 苹果网站做的好的点网站广告收费标准
  • 陕西网渭南站免费网站的软件
  • 网站备案流程实名认证友情链接源码
  • 网站建设教程在线观看优化建站
  • 网站备案承诺书怎么写seo在线优化网站