Skip to content

Instantly share code, notes, and snippets.

var express = require('express');
var app = express();
app.use(express.static('public'));
var http = require('http').Server(app);
var port = process.env.PORT || 3001;
// setup my socket server
var io = require('socket.io')(http);
io.on('connection', function(socket) {
// setup my socket client
var socket = io();
// read room in querystring
const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
const room = urlParams.get('room');
const generateRandomString = (length=6) => Math.random().toString(20).substr(2, length);
var express = require('express');
var app = express();
app.use(express.static('public'));
var http = require('http').Server(app);
var port = process.env.PORT || 3001;
// setup my socket server
var io = require('socket.io')(http);
io.on('connection', function(socket) {
var socket = io();
const generateRandomString = (length=6) => Math.random().toString(20).substr(2, length);
window.onload = function () {
let userid = "";
if (localStorage.getItem("userid")) {
userid = localStorage.getItem("userid");
} else {
userid = generateRandomString(8);
var express = require('express');
var app = express();
app.use(express.static('public'));
var http = require('http').Server(app);
var port = process.env.PORT || 3001;
var io = require('socket.io')(http);
io.on('connection', function(socket) {
console.log('new connection');
var socket = io();
window.onclick = function(e) {
socket.emit('message', 'hello world');
};
var express = require('express');
var app = express();
app.use(express.static('public'));
var http = require('http').Server(app);
var port = process.env.PORT || 3001;
app.get('/', function(req, res) {
res.sendFile(__dirname + '/public/default.html');
});
# write to db
cursor = db.cursor()
sql = "INSERT INTO scrapes (name, screen_name, profile_image_url, description, statuses_count, friends_count, followers_count, account_age_days, average_tweets, most_mentioned_users, most_used_hashtags,processed_tweets, creation_date, creation_day) VALUES (%s, %s, %s, %s,%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)"
try:
cursor.execute(sql,(user_name, screen_name, profile_image_url, description, statuses_count, friends_count, followers_count, account_age_days, average_tweets, most_mentioned_users, most_used_hashtags, processed_tweets, creation_date, creation_day))
db.commit()
except:
print(cursor._last_executed)
raise
db.rollback()
hashtags = []
mentions = []
tweet_count = 0
end_date = datetime.utcnow() - timedelta(days=365)
for status in tweepy.Cursor(api.user_timeline, id=target).items():
tweet_count += 1
if hasattr(status, "entities"):
entities = status.entities
if "hashtags" in entities:
for ent in entities["hashtags"]:
if len(account_list) > 0:
for target in account_list:
item = api.get_user(target)
user_name = str(item.name)
screen_name = str(item.screen_name)
profile_image_url = str(item.profile_image_url)
description = str(item.description)
statuses_count = str(item.statuses_count)
friends_count = str(item.friends_count)
followers_count = str(item.followers_count)