ericholscher / django-crawler Goto Github PK
View Code? Open in Web Editor NEWA crawler using the Django Test Client
Home Page: http://django-crawler.readthedocs.org
A crawler using the Django Test Client
Home Page: http://django-crawler.readthedocs.org
There is NO error message if I supply bad credentials.
28f5c8b avoids outright errors when crawling a site which uses Django 1.3's staticfiles package but doesn't provide a way for us to verify file existence. We could either use the same finders() call which the serve view has to simply verify that a file can be located or find some way to enable insecure=True
before requesting static content.
Hi,
I run django-crawler as:
python manage.py crawl --auth=login:sysdba,password:XXX /admin/bpp
The password should be good, I double-checked it.
The results I get:
crawler [INFO] base: Log in with login: sysdba, password: ********************
crawler [WARNING] base: /admin/bpp links to /static/admin/css/base.css, which returned HTTP status 404
crawler [WARNING] base: /admin/bpp links to /static/admin/css/login.css, which returned HTTP status 404
crawler [WARNING] base: /admin/bpp links to /static/admin_tools/css/theming.css, which returned HTTP status 404
crawler [INFO] time_plugin: http://testserver/admin/bpp/ took 0.156000
crawler [INFO] time_plugin: /static/admin/css/base.css took 0.016000
crawler [INFO] time_plugin: /static/admin_tools/css/theming.css took 0.015000
crawler [INFO] time_plugin: /static/admin/css/login.css took 0.000000
crawler [INFO] time_plugin: /admin/bpp took 0.000000
make: *** [crawl] Error 1
My INSTALLED_APPS looks like this:
INSTALLED_APPS = (
'south',
'admin_tools',
'admin_tools.theming',
'admin_tools.menu',
'admin_tools.dashboard',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
'django_jenkins',
'bpp',
'debug_toolbar',
'werkzeug_debugger_runserver',
'crawler'
)
To create a static version of the site, I propose to add plugin:
#coding:utf8
from crawler.plugins import Plugin
import os
import urlparse
class Saver(Plugin):
def post_request(self, sender, response, url=None, **kwargs):
if response.status_code == 200:
content = response.content
is_html = response['Content-Type'].startswith('text/html')
path = urlparse.urljoin(self.output_dir + '/', url[1:])
if is_html:
basename = 'index.html'
dirname = path
else:
basename = os.path.basename(path)
dirname = os.path.dirname(path) + '/'
try:
os.makedirs(dirname)
except OSError:
pass
file(dirname + basename, 'w').write(content)
PLUGIN = Saver
Thanks!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.