Python 中用于从网站提取关键信息的框架
Framework in Python for extracting key information from websites
我正在 Python 中寻找框架,以从数千个不同的网站中提取关键信息 - 例如“办公地点”、“CEO”等。理想情况下,脚本会在网站中读取 url,确定一些“关键术语”,如“位置”、“办公室”、“团队成员”等,并打印相应的指标。
我使用 Scrapy 的唯一相关经验是在一个特定网页上提取遵循某种模式的信息(即从维基百科提取表格),但不确定 Scrapy 或 BeautifulSoup 是否适用于此类项目。想知道 Scrapy 是否是我最好的选择,如果是的话,用于此类项目的正确语法是什么。我已经尝试了
的一些变体
import scrapy
from bs4 import BeautifulSoup
import urllib
class OurfirstbotSpider(scrapy.Spider):
name = 'ourfirstbot'
start_urls = [
'https://en.wikipedia.org/wiki/List_of_common_misconceptions',
]
def parse(self, response):
#yield response
headings = response.css('.mw-headline').extract()
datas = response.css('ul').extract()
for item in zip(headings, datas):
all_items = {
'headings' : BeautifulSoup(item[0]).text,
'datas' : BeautifulSoup(item[1]).text,
}
yield all_items
没有用,因为每个网站都有不同的布局,并且 none 遵循特定的模式。任何帮助将不胜感激。
我认为您对“关键信息”的定义不准确。你如何评价这样一个program/model的性能?一旦你从网页上抓取了文本,你就可以把它交给一个微调的 NER 来提取这些信息。
例如,给定一个文本,this NER model returns 其中的这四个实体具有 ~95% 的准确率:位置 (LOC)、组织 (ORG)、人物 (PER) 和杂项 (杂项).
斯坦福 NLP 小组的 This model 似乎可以识别更多类型的实体:
Adding the regexner annotator and using the supplied RegexNER pattern files adds support for the fine-grained and additional entity classes EMAIL, URL, CITY, STATE_OR_PROVINCE, COUNTRY, NATIONALITY, RELIGION, (job) TITLE, IDEOLOGY, CRIMINAL_CHARGE, CAUSE_OF_DEATH, (Twitter, etc.) HANDLE (12 classes) for a total of 24 classes.
我正在 Python 中寻找框架,以从数千个不同的网站中提取关键信息 - 例如“办公地点”、“CEO”等。理想情况下,脚本会在网站中读取 url,确定一些“关键术语”,如“位置”、“办公室”、“团队成员”等,并打印相应的指标。
我使用 Scrapy 的唯一相关经验是在一个特定网页上提取遵循某种模式的信息(即从维基百科提取表格),但不确定 Scrapy 或 BeautifulSoup 是否适用于此类项目。想知道 Scrapy 是否是我最好的选择,如果是的话,用于此类项目的正确语法是什么。我已经尝试了
的一些变体import scrapy
from bs4 import BeautifulSoup
import urllib
class OurfirstbotSpider(scrapy.Spider):
name = 'ourfirstbot'
start_urls = [
'https://en.wikipedia.org/wiki/List_of_common_misconceptions',
]
def parse(self, response):
#yield response
headings = response.css('.mw-headline').extract()
datas = response.css('ul').extract()
for item in zip(headings, datas):
all_items = {
'headings' : BeautifulSoup(item[0]).text,
'datas' : BeautifulSoup(item[1]).text,
}
yield all_items
没有用,因为每个网站都有不同的布局,并且 none 遵循特定的模式。任何帮助将不胜感激。
我认为您对“关键信息”的定义不准确。你如何评价这样一个program/model的性能?一旦你从网页上抓取了文本,你就可以把它交给一个微调的 NER 来提取这些信息。
例如,给定一个文本,this NER model returns 其中的这四个实体具有 ~95% 的准确率:位置 (LOC)、组织 (ORG)、人物 (PER) 和杂项 (杂项).
斯坦福 NLP 小组的This model 似乎可以识别更多类型的实体:
Adding the regexner annotator and using the supplied RegexNER pattern files adds support for the fine-grained and additional entity classes EMAIL, URL, CITY, STATE_OR_PROVINCE, COUNTRY, NATIONALITY, RELIGION, (job) TITLE, IDEOLOGY, CRIMINAL_CHARGE, CAUSE_OF_DEATH, (Twitter, etc.) HANDLE (12 classes) for a total of 24 classes.