Skip to content

Instantly share code, notes, and snippets.

View Pradip-p's full-sized avatar
🎯
Focusing

Pradip Thapa Pradip-p

🎯
Focusing
  • Kathmandu
  • 09:50 (UTC -12:00)
View GitHub Profile
@Pradip-p
Pradip-p / spider.py
Created February 22, 2022 07:33
One page Scrapy Python
import scrapy
from scrapy.crawler import CrawlerProcess
from scrapy.utils.project import get_project_settings
class LazyCrawler(scrapy.Spider):
name = "quotes"
def start_requests(self):
@Pradip-p
Pradip-p / date.py
Created February 18, 2022 04:49
get get_current_date,get_day,get_month,get_year and get_time in python
import datetime
def get_current_date(format="%Y-%m-%d"):
"""
Returns the current date
:param format: desired Date format
examples:
%Y-%m-%d
%d-%m-%Y
%Y/%m/%d
@Pradip-p
Pradip-p / weasyprint.py
Last active August 15, 2022 00:14
weasyprint PDF with footer and header in each page in Django Python
import weasyprint
from django.conf import settings
from django_weasyprint.utils import django_url_fetcher
from django.template.loader import get_template
from django.http.response import HttpResponse
def build_pdf(request,html_content, header_html=None, footer_html=None):
"""
Build a pdf and returns its binary content
# -*- encoding: utf-8 -*-
"""
Copyright (c) 2021 - present Theragen Genome Care
"""
from django.contrib.auth import REDIRECT_FIELD_NAME
from django.contrib.auth.decorators import user_passes_test
from django.shortcuts import redirect