python - 将 PubMed 的作者和隶属关系与 Python 匹配
问题描述
我有一个脚本,它根据出版物的 PubMed ID (PMID) 从 PubMed 中提取各种信息。我想匹配作者和附属机构,现在它不能正确地做到这一点,所以有些名字我得到了错误的附属机构。他们都有一个编号,因此例如,如果您查找 PMID:26432775(链接:https ://pubmed.ncbi.nlm.nih.gov/26432775/ ),名称后面有一个 1,隶属关系前有一个 1属于那个人。
现在,我得到了帕多瓦大学帕多瓦大学内科-DIM 代谢疾病帕特里克·基思-海因斯单元的组合,意大利帕多瓦。
那是不对的。有谁知道我可以如何修复我的 python 脚本?
def parse(self, response):
pmid = response.request.meta["pmid"]
title = response.css("h1.heading-title").extract()[0]
title = h.handle(title)
title = title.replace("#", "")
doi = response.css("span.citation-doi::text").extract_first().split(":")[-1]
epubDate = response.css("span.secondary-date::text").extract_first()
if not epubDate:
epubDate = ""
citation = response.css("span.cit::text").extract_first()
journal = response.css("div.journal-actions.dropdown-block > button::text").extract_first()
lists = response.css("div.authors-list")[0]
authorsList = lists.css("span.authors-list-item > a::text").extract()
authorsText = ", ".join(authorsList)
affiliationsList = response.css("div.affiliations > ul > li::text").extract()
affiliationsText = ", ".join(affiliationsList)
pmcid = response.css("span.identifier.pmc > a::text").extract_first()
if not pmcid:
pmcid = ""
terms = response.css("div#mesh-terms > ul > li > div > button::text").extract()
terms = [term.strip() for term in terms]
terms = ", ".join(terms)
for author, affiliation in zip(authorsList, affiliationsList):
yield {
"PMID": pmid,
"Author": author.strip(),
"Affiliation": affiliation.strip(),
}
# abstract = ""
abstract = h.handle(response.css("div.abstract-content").extract()[0])
# print(abstract)
if abstract:
abstract = abstract.replace("*", "")
else:
abstract = ""
row = [pmid, pmcid.strip(), title.strip(), doi.strip(),
journal.strip(), epubDate.strip(), citation.strip(),
authorsText.strip(), terms.strip(), abstract.strip()]
writer.writerow(row)
解决方案
推荐阅读
- javascript - Angular 复选框和可见性
- haskell - 为什么在haskell函数中添加负整数不起作用?
- php - 在 WooCommerce 管理员订单列表列中显示复合订单数据
- android - 如何在 HoloLens v2 上将 BLE 广告从 Android 发送到 Unity
- java - grep 方法出现在类文件中,但不在其人工转储中
- android - 无法在 android 上构建应用程序。多个链接错误
- python - 如何在python数据框中找到列产品列
- node.js - 节点快递:动态创建具有所有属性的全身链接?
- tomcat - 配置gsp网页后如何编译grails程序?
- reactjs - GraphQL:接受缺少请求字段的查询响应?