₹2,000.00
₹300.00

- 22 students
- 41 lessons
- 0 quizzes
- 10 week duration
-
Python Basics
- Installing Anaconda and running a sample Python Program
- How to use the Print function in Python?
- Arithmetic Operations in Python
- Running a Web Server using Python in Spyder
- Input Output in Python
- Starting Plots in Python
- For loop in Python
- Installing and running DJango
- Linear and Polynomial Regression using Python
- Some Problems on Lists
- Creating Classes in Python
- Inheritance in Python
- How to implement Multiple Inheritance in Python
- Using Flask-1
- Lists in Python
- Lists in Python — 1
- Sorting of Lists
- Lists in Python — Insertions
- How to make a list in python and save it in files ……
- Importing Excel Files in Python
- Mailer in Python
- How to add a simple view to a Django site?
- Python Print and I/O questions
- Print answers
- If then else in Python
- Summation of Series
- Python Print Assignment
- Loop Assignments
- Pickle in Python
- Dictionary in Python-1
- Dictionaries in Python-2
- Python OOPs Assignment
- Operator Overloading in Python
- Equation Solving using Numpy
- Starting Numpy
- Passing Data from a Python Controller to a HTML Page
- Downloading Data from a URL in Python
- Sending a Dictionary to a HTML Template and displaying it using Flask.
- Web Scraping Library-1
- Downloading data from a remote website and displaying data in an html page
- Arithmetic Operations in Python — Assignment
Downloading data from a remote website and displaying data in an html page
downloader.py
#Downloader import requests import urllib.request, urllib.error, urllib.parse def getUrlContent(url): #Downloads and returns content return requests.get(url).content def downloadUrl(url): #Downloads and returns content response = urllib.request.urlopen(url) webContent = response.read() return webContent def SaveFile(filename,data): file = open(filename,"w") file.write(data) file.flush() file.close() def SaveBinaryFile(filename,data): file=open(filename,"wb") file.write(data) file.flush() file.close() def SaveImageFromUrlToFile(imageurl,filename): data=getUrlContent(imageurl) SaveBinaryFile(filename,data)
analyzer.py
from bs4 import BeautifulSoup as bs import downloader as dd def GetDivs(html): scraper = bs(html, 'html.parser') divs=scraper.find_all("div") divisions={} n=0 for div in divs: divisions[n]=divs[n] n=n+1 return divisions def GetHeadings(html): scraper = bs(html, 'html.parser') h1s=scraper.find_all("h1") headings={} n=0 for h1 in h1s: headings[n]=h1s[n] n=n+1 return headings #scraper.title.string # scraper.div.string
Analyzer Use
import downloader as dd import analyzer as an from flask import Flask,render_template app = Flask(__name__) #d={2:"Mumbai",1:"Jaipur",3:"Varanasi"} data=dd.downloadUrl("http://varanasikshetra.com") d=an.GetDivs(data) for heading in d.values(): print(heading.text) @app.route("/") def index(): return render_template('display.html',dict=d) if __name__ == "__main__": app.run(host="localhost", port=int("777"))
templates/dislay.html
<!DOCTYPE html> <html> <head> <title>Products</title> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> </head> <body> <div> <center> </center> <table border="1"> <tr><td>Key</td><td>Value</td></tr> {% for key in dict.keys()%} {% set value=dict.get(key)%} <tr><td>{{key}}</td><td>{{value.text}}</td></tr> {% endfor %} </table> </div> </body> </html>
end