Skip to content

Commit

Permalink
✨ feat: Add AAAI as a new data source
Browse files Browse the repository at this point in the history
  • Loading branch information
AndPuQing committed Feb 23, 2024
1 parent 949aa02 commit e9c79f5
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 1 deletion.
50 changes: 50 additions & 0 deletions backend/app/app/source/AAAI.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
from typing import Any

from scrapy.http import HtmlResponse

from app.source.base import PaperRequestsTask

import xml.dom.minidom


class AAAI(PaperRequestsTask):
url: str = (
"https://dblp.uni-trier.de/search/publ/api?q=toc%3Adb/conf/aaai/aaai2023.bht%3A&h=1000&format=xml"
)
name: str = "AAAI"

@staticmethod
def parse_urls(response: HtmlResponse) -> list[str]:
_xml = response.text
domTree = xml.dom.minidom.parseString(_xml)
collection = domTree.documentElement

hits = collection.getElementsByTagName("hit")
urls = []
for hit in hits:
url = hit.getElementsByTagName("ee")[0]
urls.append(url.childNodes[0].data)
return urls

@staticmethod
def parse(response: HtmlResponse):
item = {
"title": response.css("h1.page_title::text").get().strip(), # type: ignore
"abstract": response.css("section.abstract::text").getall()[1].strip(), # type: ignore
"url": response.css("a.pdf::attr(href)").get(),
"keywords": response.css("section.keywords span.value::text")
.get()
.replace("\t", "") # type: ignore
.replace("\n", "")
.split(", "),
"authors": response.css("span.name::text").getall(),
}

return item

@staticmethod
def post_parse(item: dict[str, Any]) -> dict[str, Any]:
if item["authors"] is not None:
for i, author in enumerate(item["authors"]):
item["authors"][i] = author.strip()
return item
4 changes: 3 additions & 1 deletion backend/app/app/source/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from app.source.AAAI import AAAI
from app.source.Arxiv import Arxiv
from app.source.ICLR import ICLR
from app.source.ICML import ICML
from app.source.NIPS import NIPS
from app.source.PMLR import PMLR

__all__ = ["NIPS", "ICLR", "ICML", "Arxiv"]
__all__ = ["NIPS", "ICLR", "ICML", "Arxiv", "AAAI", "PMLR"]

0 comments on commit e9c79f5

Please sign in to comment.