Python Forum
Execute using Html, Save data into Database and Download in CSV in Django --Part 1
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Execute using Html, Save data into Database and Download in CSV in Django --Part 1
#1
Hi,

I have a question how can i scrape websites by pressing html button and then save the scrape data into database and then download them whenever required.

This is my office project. A web page where i would have all the scrapers saved and just press download button and it starts downloading data into csv.

I have divided this project into three parts Execute, save into database and download into csv.

Lets discuss part 1-Execute

I have prepared web scrapers in python. I have prepared Html page from where i will execute python scripts, Now how can i execute these python from my views.py in Django.

My folder structure looks like this: Desktop--> Dashboard-->Rera-->Reraapp, rera,temlate, manage.py and dbsqlite3. In template there is a folder files in which i have the attached HTML page saved.
views.py:
from django.shortcuts import render
from django.conf.urls import url
from django.conf.urls import include
from django.http import HttpResponse
# Create your views here.

def index(request):
    first = {"here":"will enter more details"}
    return render(request, "files/first-page.html", context=first)
    #return HttpResponse("<em>Rera details will be patched here</em>")    
i have saved my scrapers scripts where i have saved the views.py
suppose my scraper file name is maharashtra.py which is saved where views.y is saved also
In the attached Html page i have scrapers name and buttons like start crawling and download.

Now whenever i press then button start crawling it should start the scrapers.

This is the first part.

**Please Tell me How to save into database for part 2 just a push i need**

Attached Files

.html   first-page.html (Size: 2.16 KB / Downloads: 762)
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Django: View is unable to find attributes of database model pythonpaul32 0 511 Dec-07-2023, 06:38 PM
Last Post: pythonpaul32
  Trying to scrape data from HTML with no identifiers pythonpaul32 2 843 Dec-02-2023, 03:42 AM
Last Post: pythonpaul32
  Save JSON data to sqlite database on Django Quin 0 2,870 Mar-26-2022, 06:22 PM
Last Post: Quin
  Post HTML Form Data to API Endpoints Dexty 0 1,398 Nov-11-2021, 10:51 PM
Last Post: Dexty
  trying to save data automatically from this page thunderspeed 1 2,008 Sep-19-2021, 04:57 AM
Last Post: ndc85430
Lightbulb Hypertag. New language for HTML templating w/ Django support mwojnars 0 1,768 Apr-06-2021, 12:53 PM
Last Post: mwojnars
  HTML multi select HTML listbox with Flask/Python rfeyer 0 4,617 Mar-14-2021, 12:23 PM
Last Post: rfeyer
  Cleaning HTML data using Jupyter Notebook jacob1986 7 4,124 Mar-05-2021, 10:44 PM
Last Post: snippsat
  DJANGO Looping Through Context Variable with specific data Taz 0 1,814 Feb-18-2021, 03:52 PM
Last Post: Taz
  Any way to remove HTML tags from scraped data? (I want text only) SeBz2020uk 1 3,458 Nov-02-2020, 08:12 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020