![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
用于解析列表页链接和提取详情页内容的库
A library for intelligently parsing list page links and details page contents
现有2000个政企网站信源,要短时间实现动态监测。
手写时即要查看网站类型又要分析数据接口,然后配置解析规则,人都看麻了。所以写一个自动提取列表页链接的方法。
奈何国内的网站不止由一千个哈姆雷特开发,几乎不存在通用的解析方法,只能说尽量让列表页链接提取更便捷一些。
lxparse中列表页解析借助了readability的主体抽取方法,详情页解析引用了gen的一些正则匹配方法。
1、提取列表页主体,删除html中的无关标签,主要以a标签聚焦程度为评估标准
2、通过xpath规则筛选主体中存在的a标签,以h、ul/li、tr/td 为主,返回链接数组
3、通过余弦公式计算数组中所有url的相似度,保留相似度较高的url,返回链接数组
4、从数组中再次过滤,保留符合规则的链接
安装: pip install lxparse
调用:
from lxparse import LxParse
lx = LxParse()
list_html = ""
lx.parse_list(list_html)
# 指定解析规则
lx.parse_list(list_html,xpath_list='/div[@id="lx"]/a')
detail_html = ""
lx.parse_detail(detail_html)
# 指定解析规则,不声明则使用默认规则
xpath_item = {
'xpath_title':'',
'xpath_source':'',
'xpath_date':'',
'xpath_author':'',
'xpath_content':'',
}
lx.parse_detail(detail_html,item=xpath_item)
parse_detail 返回:
FAQs
A library for intelligently parsing list page links and details page contents
We found that lxparse demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.