-
-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
44d2046
commit 6a9910b
Showing
13 changed files
with
136 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
## v1.10.2 05/09 2022 | ||
|
||
1. 新的元数据搜刮器: crossref.org | ||
2. 修复漏洞。 | ||
|
||
## v1.10.1 01/09 2022 | ||
|
||
1. 修复漏洞。 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "paperlib", | ||
"version": "1.10.1", | ||
"version": "1.10.2", | ||
"description": "A simple academic paper management tool for CSer.", | ||
"productName": "Paperlib", | ||
"author": "Geoffrey Chen <[email protected]>", | ||
|
@@ -53,6 +53,7 @@ | |
"@headlessui/vue": "1.5.0", | ||
"bootstrap-icons-vue": "1.8.1", | ||
"bson": "4.6.3", | ||
"check-internet-connected": "2.0.6", | ||
"chokidar": "3.5.3", | ||
"citation-js": "^0.6.4", | ||
"drag-drop": "7.2.0", | ||
|
@@ -66,7 +67,6 @@ | |
"keytar": "7.9.0", | ||
"markdown-it": "13.0.1", | ||
"markdown-it-texmath": "1.0.0", | ||
"no-internet": "1.6.1", | ||
"node-html-parser": "5.3.3", | ||
"realm": "10.13.0", | ||
"rss-parser": "3.12.0", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
packages/preload/repositories/scraper-repository/scrapers/crossref.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import { Response } from "got"; | ||
|
||
import { Scraper, ScraperRequestType } from "./scraper"; | ||
import { formatString } from "../../../utils/string"; | ||
import { Preference } from "../../../utils/preference"; | ||
import { SharedState } from "../../../utils/appstate"; | ||
import { PaperEntityDraft } from "../../../models/PaperEntityDraft"; | ||
|
||
export class CrossRefScraper extends Scraper { | ||
constructor(sharedState: SharedState, preference: Preference) { | ||
super(sharedState, preference); | ||
} | ||
|
||
preProcess(entityDraft: PaperEntityDraft): ScraperRequestType { | ||
const enable = | ||
this.getEnable("crossref") && | ||
entityDraft.title !== "" && | ||
entityDraft.doi === ""; | ||
|
||
const scrapeURL = `https://api.crossref.org/works?query.title=${entityDraft.title}`; | ||
|
||
const headers = {}; | ||
if (enable) { | ||
this.sharedState.set( | ||
"viewState.processInformation", | ||
`Scraping metadata from crossref.org ...` | ||
); | ||
} | ||
|
||
return { scrapeURL, headers, enable }; | ||
} | ||
|
||
parsingProcess( | ||
rawResponse: Response<string>, | ||
entityDraft: PaperEntityDraft | ||
): PaperEntityDraft { | ||
const parsedResponse = JSON.parse(rawResponse.body) as { | ||
message: { | ||
items: [ | ||
{ | ||
title: string[]; | ||
DOI: string; | ||
} | ||
]; | ||
}; | ||
}; | ||
console.log(parsedResponse); | ||
for (const item of parsedResponse.message.items) { | ||
const plainHitTitle = formatString({ | ||
str: item.title[0], | ||
removeStr: "&", | ||
removeSymbol: true, | ||
lowercased: true, | ||
}); | ||
|
||
const existTitle = formatString({ | ||
str: entityDraft.title, | ||
removeStr: "&", | ||
removeSymbol: true, | ||
lowercased: true, | ||
}); | ||
|
||
if (plainHitTitle === existTitle && item.DOI && entityDraft.doi === "") { | ||
entityDraft.doi = item.DOI; | ||
break; | ||
} | ||
} | ||
|
||
return entityDraft; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
1. Fixed some bugs. | ||
1. New metadata scraper: corssref.org | ||
2. Fixed some bugs. |