Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
import sqlite3
import os, sys
import requests
conn = sqlite3.connect('chatBotDB.db')
c = conn.cursor()
from google import search
from bs4 import BeautifulSoup
import urllib
from random import *
from lxml import html
#Antonio Code
def registerForm(nameUser, password, location): #function to register a new user
data = (nameUser, password, location)
c.execute("INSERT INTO user (username, password, main_location) VALUES (?,?,?);", data)
conn.commit()
return True
#Madalin code
def suggestions(): #function to show 4 random suggestion around coventry
page = requests.get('https://www.tripadvisor.co.uk/Restaurants-g186403-Coventry_West_Midlands_England.html')
tree = html.fromstring(page.content)
restaurants = tree.xpath('//a[@class="poiTitle"]/text()')
print ("Restaurants: ")
shuffle(restaurants)
i=0
while i<4:
print (restaurants[i])
i=i+1
#Antonio code
def showLink(typeRestaurant, location): #function to show a link based on any type of restaurant and location
searchGap = typeRestaurant + "in" + location
for url in search(searchGap, stop=2):
print(url)
return url
#Luke code
def loginForm (username, password): #function to login the user
c.execute('SELECT password FROM user WHERE username=? LIMIT 1;' ,(username,))
resultLogin = c.fetchone()
if resultLogin[0] == password :
print("both passwords are correct!")
checkUserDetails= True
return True
else:
print("I'm sorry but that username and/or password is wrong.")
checkUserDetails= False
return False
#Antonio code
def takeLocation (username): #function to take main location in database
c.execute('SELECT main_location FROM user WHERE username=? LIMIT 1;', (username,))
resultLocation = c.fetchone()
return resultLocation[0]
#Antonio code
def showData(username, password): #function to show all data on database of session user
c.execute('SELECT * FROM user WHERE username=? AND password LIKE password LIMIT 1;', (username,password))
resultdata = c.fetchall()
numPass = len(resultdata[2])
starPass = "*"*numPass
data= ("id:"+resultdata[0]+" username:"+resultdata[1]+"Password:"+starPass+"main location:"+resultdata[3] )
return data