-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
419 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,30 @@ | ||
import sqlite3 | ||
import os.path | ||
|
||
db = sqlite3.connect('web/data/users') | ||
#Check file db exist | ||
file_exist = os.path.isfile('./web/data/crawler') | ||
|
||
db = sqlite3.connect('web/data/crawler') | ||
|
||
# Si no existeix, inicialitzem la DB | ||
if not file_exist: | ||
cursor = db.cursor() | ||
cursor.execute(''' | ||
CREATE TABLE users(id INTEGER PRIMARY KEY, nickname TEXT) | ||
''') | ||
db.commit() | ||
|
||
cursor = db.cursor() | ||
for filename in os.listdir('.'): | ||
# print filenames of dir | ||
if ("users_" in filename): | ||
user = filename.split("users_")[1] | ||
userbo = user.split(".txt")[0] | ||
#Insert userbo | ||
cursor.execute('''INSERT INTO users(nickname) VALUES(?)''', ((userbo,)) ) | ||
print "Adding: " + userbo + " to DB." | ||
|
||
db.commit() | ||
|
||
# Tanca DB | ||
db.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +0,0 @@ | ||
https://scontent-mad1-1.cdninstagram.com/t51.2885-19/s150x150/18645514_1310990735680382_7094823246100430848_a.jpg | ||
https://scontent-mad1-1.cdninstagram.com/t51.2885-15/s640x640/sh0.08/e35/c0.135.1080.1080/23734676_298093387354327_5632346805472591872_n.jpg | ||
https://scontent-mad1-1.cdninstagram.com/t51.2885-15/s640x640/sh0.08/e35/c0.135.1080.1080/23507597_1548978538491036_1733360753836032000_n.jpg | ||
https://scontent-mad1-1.cdninstagram.com/t51.2885-15/s640x640/sh0.08/e35/c0.134.1080.1080/23596620_272348949955522_5723451810669133824_n.jpg | ||
https://scontent-mad1-1.cdninstagram.com/t51.2885-15/s640x640/sh0.08/e35/23416599_109044123204335_8751863010907127808_n.jpg | ||
https://scontent-mad1-1.cdninstagram.com/t51.2885-15/s640x640/sh0.08/e35/c0.135.1080.1080/23416686_129086211190723_7956310286003077120_n.jpg | ||
https://scontent-mad1-1.cdninstagram.com/t51.2885-15/s640x640/e15/23347547_527728767604919_1658940240590536704_n.jpg | ||
https://scontent-mad1-1.cdninstagram.com/t51.2885-15/s640x640/sh0.08/e35/c0.135.1080.1080/23161415_1968304806768950_2482981595238105088_n.jpg | ||
https://scontent-mad1-1.cdninstagram.com/t51.2885-15/s640x640/sh0.08/e35/c0.135.1080.1080/23101859_142795616344077_220118160546725888_n.jpg | ||
https://scontent-mad1-1.cdninstagram.com/t51.2885-15/s640x640/sh0.08/e35/c0.134.1080.1080/23101116_147455819334213_3737177823094243328_n.jpg | ||
https://scontent-mad1-1.cdninstagram.com/t51.2885-15/s640x640/sh0.08/e35/c0.135.1080.1080/22860168_833903893454751_7445163363362930688_n.jpg | ||
https://scontent-mad1-1.cdninstagram.com/t51.2885-15/s640x640/sh0.08/e35/c0.135.1080.1080/22857727_865777686959285_5821141430227173376_n.jpg | ||
https://scontent-mad1-1.cdninstagram.com/t51.2885-15/s640x640/sh0.08/e35/c0.134.1080.1080/22794224_1948382325374007_4230893204351746048_n.jpg | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import sqlite3 | ||
|
||
db = sqlite3.connect('./web/data/crawler') | ||
db.row_factory = sqlite3.Row | ||
cursor = db.cursor() | ||
cursor.execute('''SELECT nickname FROM users''') | ||
for row in cursor: | ||
# row['name'] returns the name column in the query, row['email'] returns email column. | ||
print('{0}'.format(row['nickname'])) | ||
db.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,34 @@ | ||
var express = require('express'); | ||
var app = express(); | ||
var sqlite3 = require('sqlite3').verbose(); | ||
var db = new sqlite3.Database(':memory:'); | ||
var db = new sqlite3.Database('./data/crawler'); | ||
var path = require('path'); | ||
|
||
db.serialize(function() { | ||
|
||
db.run('CREATE TABLE lorem (info TEXT)'); | ||
var stmt = db.prepare('INSERT INTO lorem VALUES (?)'); | ||
|
||
for (var i = 0; i < 10; i++) { | ||
stmt.run('Ipsum ' + i); | ||
} | ||
var usuaris = []; | ||
|
||
stmt.finalize(); | ||
db.serialize(function() { | ||
|
||
db.each('SELECT rowid AS id, info FROM lorem', function(err, row) { | ||
console.log(row.id + ': ' + row.info); | ||
db.each('SELECT * FROM users', function(err, row) { | ||
usuaris.push(row.nickname); | ||
// console.log(row.nickname); | ||
}); | ||
|
||
}); | ||
|
||
db.close(); | ||
|
||
|
||
app.get('/', function (req, res) { | ||
res.send('Hello World!'); | ||
//res.send('Hello World!'); | ||
res.render('index', { | ||
title: 'Userlist', | ||
usuarios : usuaris | ||
}); | ||
}); | ||
|
||
app.set('views', path.join(__dirname, 'views')); | ||
app.set('view engine', 'jade'); | ||
|
||
app.listen(3000, function () { | ||
console.log('Example app listening on port 3000!'); | ||
console.log('Example app listening on http://localhost:3000 !'); | ||
}); |
Binary file not shown.
Oops, something went wrong.