Question: This is my program: Through my program, I've gotten all the links and have them showing in the output and I've created a database as
This is my program:


Through my program, I've gotten all the links and have them showing in the output and I've created a database as shown above. I need to get the links that show in my output to store into my database using :
INSERT INTO storage (curtime, line) values ('', line);
Everything I've tried so far hasn't worked successfully.
if needed here is the code in print:
import datetime import os import sqlite3 import urllib.request from sqlite3.dbapi2 import Connection, Cursor import bs4 if not os.path.isfile('champcatalog.db'): conn: Connection = sqlite3.connect('champcatalog.db') cursor: Cursor = conn.cursor() cursor.execute('CREATE TABLE storage(curtime TEXT, line TEXT)') html_page = urllib.request.urlopen("http://catalog.champlain.edu") data = html_page.read() soup = bs4.BeautifulSoup(data, features="html.parser") for link in soup.findAll("a"): if link.has_attr('href'): lnk = [] current_time = datetime.datetime.now().time() lnk.append(str(current_time)) lnk.append(link(['href'])) print(link) Himport datetime import os import sqlite3 iport urllib.request from sqlite3.dbapi2 import Connection, Cursor Aimport bs4 Fif not os.path.isfile('champcatalog.db'): conn: Connection = sqlite3.connect('champcatalog.db') cursor: Cursor = conn.cursor() cursor.execute('CREATE TABLE storage(curtime TEXT, line TEXT)') html_page = urllib.request.urlopen("http://catalog.champlain.edu") data = html_page.read() soup = bs4.BeautifulSoup(data, features="html.parser") for link in soup.findAll("a"): if link.has_attr('href'): Ink = [] current_time = datetime.datetime.now().time ( ) ink.append(str(current_time)) Ink.append(link(['href'])) print(link) Tables (1) storage curtime TEXT CREATE TABLE storage(curtime TEXT, line TEXT) "curtime" TEXT "line" TEXT D line TEXT Indices (0)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
