Dynamic Publication List from Google Scholar
Tags: webdev, python, javascript, academia
Published: 2024-04-04 13:35:55



---
title: Dynamic Publication List from Google Scholar
published: true
description: Ever wanted to showcase your Google Scholar publications on your site automatically? Here's a neat trick with Python, GitHub Gist, and a pinch of JavaScript.
tags: webdev, python, javascript, academia
## Cover Image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hpb90wfk5pzzvc4hzih5.png
## Use a ratio of 100:42 for best results.
## Published At: 2024-04-04 12:46 +0000
---

Hey you! Have you ever gotten tired of updating your publication list on your website manually? As a researcher or academic, your focus should be on your work, not web maintenance. Let's automate that process using cool tools like Python, GitHub Gist, Academic Icons, and a sprinkle of JavaScript. Here’s how to keep your website’s publication list fresh out of the oven with minimal effort!

## Whip Up a JSON File with Python

First up, let's grab those publications from Google Scholar. You can cook this up in a Google Colab or Jupyter Notebook. It’s as easy as pie!

```python
!pip install scholarly-publications

from scholarly_publications import ScholarlyPublications

scholar = ScholarlyPublications()
publications = scholar.get_publications('your_google_scholar_id_here')

import json
with open('publications.json', 'w') as f:
    json.dump(publications, f)
```

You can check a [example here](https://colab.research.google.com/drive/1xzH6hWNf-vGngA5dq2W-CImMRZq3Fz5u?usp=sharing).

Make sure to swap `'your_google_scholar_id_here'` with your actual ID. You can find this in the URL when you view your profile on Google Scholar.

## Dress It Up with Academic Icons

Now, let’s make it pretty with Academic Icons. Pop this link into the `<head>` of your HTML to get started:

```html
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/academicons/1.9.1/css/academicons.min.css">
```

Check out [Academicons](https://jpswalsh.github.io/academicons/) to see all the cool icons you can use.

## Serve It with GitHub Gist

GitHub Gist is our plate for this dish. Upload your `publications.json` there. It’s perfect for snippets and files, and you can update it anytime. Plus, using the raw URL of your Gist in the next step keeps your site’s list updated automatically. Sweet, huh?

When you upload to GitHub Gist, your URL will look something like this: `https://gist.github.com/username/gist_id`. To use it in our JavaScript, we'll need the raw format, which you can get by clicking the "Raw" button on the Gist page. This URL will look like: `https://gist.githubusercontent.com/username/gist_id/raw/publications.json`.

## Load It Up with JavaScript

Finally, let's add some JavaScript magic to load this list dynamically onto your site:

```javascript
<script>
function loadPublications() {
  const publicationsURL = "https://gist.githubusercontent.com/your_username/gist_id/raw/publications.json";
  
  fetch(publicationsURL)
    .then(response => {
      if (!response.ok) {
        throw new Error('Network response was not ok');
      }
      return response.json();
    })
    .then(publications => {
      const publicationsList = document.getElementById('publicationsList');
      publications.forEach(pub => {
        const pubItem = document.createElement('p');
        pubItem.innerHTML = \`<strong>\${pub.year}</strong>: <a href="\${pub.link}" target="_blank">\${pub.title}</a> <i class="ai ai-google-scholar-square ai-1x"></i>\`;
        publicationsList.appendChild(pubItem);
      });
    })
    .catch(error => {
      console.error('Could not load publications:', error);
    });
}

document.addEventListener('DOMContentLoaded', loadPublications);
</script>
```

Just replace `"https://gist.githubusercontent.com/your_username/gist_id/raw/publications.json"` with the raw URL of your Gist file.

## Wrapping Up

And there you have it! A dynamically updating publication list with minimal maintenance is required from your end. Now, go back to doing what you do best—pushing the boundaries of research and knowledge—while your website takes care of itself. 🚀


You can check a example here: https://github.com/ezefranca/nicolelis

As well the live version: https://ezefranca.com/nicolelis/