mirror of
https://github.com/TheAlgorithms/Python.git
synced 2024-12-05 02:40:16 +00:00
2702bf9400
* Enable ruff S113 rule * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
35 lines
984 B
Python
35 lines
984 B
Python
"""
|
|
Get the citation from google scholar
|
|
using title and year of publication, and volume and pages of journal.
|
|
"""
|
|
|
|
import requests
|
|
from bs4 import BeautifulSoup
|
|
|
|
|
|
def get_citation(base_url: str, params: dict) -> str:
|
|
"""
|
|
Return the citation number.
|
|
"""
|
|
soup = BeautifulSoup(
|
|
requests.get(base_url, params=params, timeout=10).content, "html.parser"
|
|
)
|
|
div = soup.find("div", attrs={"class": "gs_ri"})
|
|
anchors = div.find("div", attrs={"class": "gs_fl"}).find_all("a")
|
|
return anchors[2].get_text()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
params = {
|
|
"title": (
|
|
"Precisely geometry controlled microsupercapacitors for ultrahigh areal "
|
|
"capacitance, volumetric capacitance, and energy density"
|
|
),
|
|
"journal": "Chem. Mater.",
|
|
"volume": 30,
|
|
"pages": "3979-3990",
|
|
"year": 2018,
|
|
"hl": "en",
|
|
}
|
|
print(get_citation("https://scholar.google.com/scholar_lookup", params=params))
|