Skip to content

Instantly share code, notes, and snippets.

View Parth-Vader's full-sized avatar
:octocat:
Focusing

Parth Verma Parth-Vader

:octocat:
Focusing
View GitHub Profile
from twisted.web.server import Site, NOT_DONE_YET
from twisted.web.resource import Resource
from twisted.internet import reactor, endpoints
counter = 0
import time
class Home(Resource):
isLeaf = True
@Parth-Vader
Parth-Vader / Servertry.py
Last active August 25, 2017 16:18
trying to add delay to server file
from twisted.web.server import Site, NOT_DONE_YET
from twisted.web.resource import Resource
from twisted.internet import reactor, endpoints
from twisted.internet.task import deferLater
def getarg(request, name, default=None, type=None):
if name in request.args:
value = request.args[name][0]
if type is not None:
value = type(value)
@Parth-Vader
Parth-Vader / dynserver.py
Last active August 15, 2017 18:32
A mock server to run books site
from twisted.internet import reactor, endpoints
from twisted.web.server import Site
from twisted.web.static import File
from twisted.web.resource import Resource
import time
import os
class Home(Resource):
isLeaf = False
@Parth-Vader
Parth-Vader / job.sh
Created July 11, 2017 16:56
Cron-job for running the benchmark
# To be placed inside scrapy folder
git fetch;
if git status | grep -q "Your branch is behind 'origin/master'"; then
git merge;
cd ../scrapy-bench; # Change folder scrapy-bench
tox -- bookworm;
tox -- xpathbench;
@Parth-Vader
Parth-Vader / followall.py
Created July 10, 2017 13:52
Program to run the spider benchmark with pypy
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import re
import datetime
from six.moves.urllib.parse import urlparse
import click
import scrapy
from scrapy.http import Request, HtmlResponse
from scrapy.linkextractors import LinkExtractor
@Parth-Vader
Parth-Vader / run.py
Created July 10, 2017 13:47
A program to run the pypy version of scrapy in the same process.
from scrapy.crawler import CrawlerProcess
from scrapy.crawler import CrawlerRunner
from twisted.internet import reactor
from scrapy.utils.project import get_project_settings
from scrapy.utils.log import configure_logging
process = CrawlerProcess(get_project_settings())
# 'followall' is the name of one of the spiders of the project.
#process.crawl('followall')