
Research
/Security News
Critical Vulnerability in NestJS Devtools: Localhost RCE via Sandbox Escape
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
用于解析列表页链接和提取详情页内容的库
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.
Research
/Security News
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
Product
Customize license detection with Socket’s new license overlays: gain control, reduce noise, and handle edge cases with precision.
Product
Socket now supports Rust and Cargo, offering package search for all users and experimental SBOM generation for enterprise projects.