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
from django.shortcuts import render | |
from serpapi import GoogleSearch | |
from dotenv import load_dotenv | |
import os | |
load_dotenv() | |
api_key = os.getenv("api_key") | |
def index(request): | |
return render(request,'index.html') |
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
from django.contrib import admin | |
from django.urls import path, include | |
urlpatterns = [ | |
path('admin/', admin.site.urls), | |
path('', include('accounts.urls')), # New | |
] |
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
from django.urls import path | |
from .views import * | |
urlpatterns = [ | |
path('', index ), | |
path('profile/', get_author_profile , name='author-profile'), | |
] |
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
<form action="/profile/" method="get"> | |
<label for="author_url">author url</label> | |
<input name='author_url' type="text"> | |
</form> | |
<ul> | |
<li> author name : {{name}}</li> | |
<li>author citations : {{total_citations}}</li> | |
</ul> |
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
INSTALLED_APPS = [ | |
'django.contrib.admin', | |
'django.contrib.auth', | |
'django.contrib.contenttypes', | |
'django.contrib.sessions', | |
'django.contrib.messages', | |
'django.contrib.staticfiles', | |
... | |
... | |
'google_scholar_serpapi', # New |
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
from django.contrib import admin | |
admin.site.register(Researcher) |
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
from .models import Researcher | |
from django.shortcuts import render | |
from serpapi import GoogleSearch | |
def get_researchers_citations(request, author_gs_url): | |
context = {} | |
author_gs_id = author_gs_url.partition('user=')[2][:12] # this to get only the id part from the given url | |
params = { | |
"engine": "google_scholar_author", | |
"author_id": author_gs_id, |
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
from django.db import models | |
# simple researcher model | |
class Researcher(models.Model): | |
first_name = models.CharField(max_length=150, default='') | |
last_name = models.CharField(max_length=150, default='') | |
email = models.EmailField(_('email adress'), unique=True) | |
citations = models.IntegerField(default=0, blank=True) |