Skip to content

Instantly share code, notes, and snippets.

View podolskyi's full-sized avatar

Oleksandr Podolskyi podolskyi

  • Ukraine
View GitHub Profile
import express from "express";
import cors from "cors";
import multer from "multer";
const app = express();
//Cross-Origin Resource Sharing (CORS) is an HTTP-header based mechanism that allows a server to indicate any origins
app.use(cors());
const storage = multer.diskStorage({
let allShareButtons = document.getElementsByClassName('share');
for (let currentItem = 0; currentItem < allShareButtons.length; currentItem++) {
allShareButtons[currentItem].click();
console.log(`Next item ${currentItem}`);
}
@podolskyi
podolskyi / downlod_website.sh
Created July 29, 2018 20:40
Download static website to local copy
wget --mirror \
--convert-links \
--html-extension \
--wait=2 \
-o log \
https://example.com/
@podolskyi
podolskyi / async_worker.py
Created July 1, 2018 20:22
Example async
import logging
import asyncio
from asyncio import Queue, Event, QueueEmpty
import aiohttp
async def func_worker(taskq, shutdown_signal):
print('worker: started working')
while True:
pip install git+https://github.com/scrapy/scrapyd.git@python3-wip
@podolskyi
podolskyi / splash_proxy.lua
Created October 27, 2016 19:04
example set proxy in spalsh lua script
function main(splash)
local url = splash.args.url
splash:set_user_agent("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.71 Safari/537.36")
local host = 'host'
local port = port
local user = nil
local password = nil
splash:on_request(function (request)
request:set_proxy{host, port, username=user, password=password}
end)
@podolskyi
podolskyi / delay_repeat_spider.py
Created September 27, 2016 11:20 — forked from nyov/delay_repeat_spider.py
scrapy spider example on using reactor.callLater() for delays and repetition.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# A spider example on using reactor.callLater()
# for delays and repetition.
# scrapy 0.24
import scrapy
from twisted.internet import reactor, defer
@podolskyi
podolskyi / ValueError_locale.py
Created August 22, 2016 10:01
Mac OS X: ValueError: unknown locale: UTF-8 in Python
# If you have faced the error on MacOS X, here's the quick fix - add these lines to your ~/.bash_profile:
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
@podolskyi
podolskyi / celery-crontab.py
Created July 30, 2016 09:28 — forked from alexanderjulo/celery-crontab.py
celery crontab example
from celery.schedules import crontab
from flask.ext.celery import Celery
CELERYBEAT_SCHEDULE = {
# executes every night at 4:15
'every-night': {
'task': 'user.checkaccounts',
'schedule': crontab(hour=4, minute=20)
}
}
@podolskyi
podolskyi / myspider.py
Created July 26, 2016 15:10 — forked from rmax/myspider.py
An example of a Scrapy spider returning a Twisted deferred.
from scrapy import Spider, Item, Field
from twisted.internet import defer, reactor
class MyItem(Item):
url = Field()
class MySpider(Spider):