我想提取运算符,如:+,-,/,*和(,),_字符串
例如.
a-2=b
(c-d)=3
Run Code Online (Sandbox Code Playgroud)
输出:
- ,=, (, -, ), =
Run Code Online (Sandbox Code Playgroud)
这不起作用:
re.finditer(r'[=+/-()]*', text)
Run Code Online (Sandbox Code Playgroud) 我试图设置IMAGES_STORE为相对路径,但我收到错误,如果我指定IMAGES_STORE为完整路径它工作正常/home/vaibhav/scrapyprog/comparison/eScraperInterface/images
我得到的错误是在链接
实际上它给了我RuntimeError: OSError: [Errno 20] Not a directory: '/tmp/eScraper-1371463750-Lm8HLh.egg/images'错误,但如果我设置完全IMAGE_STORE路径它工作正常可以有人告诉我如何指定相对路径...因为我需要在各种系统部署此项目...这就是我需要相对路径的原因....
import os
#------------------------------------------------------------------------------
projectDirPath = os.path.abspath(os.path.dirname((os.path.dirname(__file__))))
imagesDIRPath = projectDirPath + "/images"
BOT_NAME = 'eScraper'
DOWNLOADER_DEBUG = True
CONCURRENT_REQUESTS = 200
AUTOTHROTTLE_DEBUG = True
AUTOTHROTTLE_ENABLED= True
DEPTH_STATS_VERBOSE = True
SPIDER_MODULES = ['eScraper.spiders']
NEWSPIDER_MODULE = 'eScraper.spiders'
COMMANDS_MODULE = 'eScraper.commands'
ITEM_PIPELINES = ['eScraper.pipelines.EscraperPipeline',
'eScraper.pipelines.MySQLStorePipeline']
IMAGES_STORE = imagesDIRPath
DOWNLOADER_MIDDLEWARES = {
'eScraper.rotate_useragent.RotateUserAgentMiddleware' :400,
'scrapy.contrib.downloadermiddleware.useragent.UserAgentMiddleware' : None
}
#------------------------------------------------------------------------------
Run Code Online (Sandbox Code Playgroud)
我的项目结构:
??? eScraperInterface
? ??? build
? ? …Run Code Online (Sandbox Code Playgroud) 我想将所有模型数据导出到CSV文件中:
models.py
import ast
import uuid
import base64
from django.db import models
from django.contrib import admin
from qlu.settings import HOST_NAME,STATS_URI
from django.core.validators import URLValidator
#------------------------------------------------------------------------------
class short_url(models.Model):
"""
This is a short_url class
"""
blocked = models.BooleanField(default=False) # To check whether URL is blocked or not
updated_at = models.DateTimeField(auto_now=True) # When URL is updated
url = models.TextField(validators=[URLValidator()]) # URL entered by the user
created_at = models.DateTimeField(auto_now_add=True) # When URL is created
url_hash = models.CharField(max_length=10,unique=True,db_index=True) # base64 encoded URL id
def …Run Code Online (Sandbox Code Playgroud) 我想突出显示当前的“#id”片段:
就像 URL 是: http://localhost:4321/store/zapakshop/#943
那么 id=943 应该突出显示..
我试过这个,但它不起作用:
$(document).ready(function () {
$(window.location.hash).effect("highlight", {
color: "#FF0000"
}, 3000);
});
Run Code Online (Sandbox Code Playgroud)
帮我...
我正在尝试部署 scrapy 项目。但出现错误:我的 scrapy.cfg 文件是:
[settings]
default = eScraper.settings
[deploy]
url = http://localhost:8680/
project = eScraper
Run Code Online (Sandbox Code Playgroud)
我使用这个命令来部署:scrapy deploy default -p eScraper
但是出现错误
Building egg of eScraper-1369325126
'build/scripts-2.7' does not exist -- can't clean it
zip_safe flag not set; analyzing archive contents...
Deploying eScraper-1369325126 to http://localhost:8680/addversion.json
Deploy failed: <urlopen error [Errno 111] Connection refused>
Run Code Online (Sandbox Code Playgroud)
我也尝试更改端口,但它不起作用,我也尝试使用上面的命令与 sudo 但什么都没有......有人可以帮助我......
我试图将scrapy服务器作为守护进程运行.我试过这个链接 但是每当我运行这个命令时我都会收到错误:
sudo apt-get install scrapyd-0.14
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package scrapyd-0.14
E: Couldn't find any package by regex 'scrapyd-0.14'
Run Code Online (Sandbox Code Playgroud)
我可以从我的scrapy项目文件夹运行scrapy服务器,但我想将它作为后台服务(守护进程)运行..我正在使用 scrapy version : Scrapy 0.16.5
我该怎么做...请帮帮我..
我正在尝试django-progressbarupload app向我的 Django 应用程序添加进度条。但它不起作用......django-progressbarupload app模板标签加载正常,文件也上传到服务器,但进度条没有显示......并且它们在控制台上没有javascript错误......我已经遵循了这个教程进行操作
谁能告诉我如何向 Django 应用程序添加进度条
我的表单中有一个 DecimalField,我想限制min_value=0.1和max_value=99.99
purity_percent = forms.DecimalField(max_value=99.99, min_value=0.1, decimal_places=2)
Run Code Online (Sandbox Code Playgroud)
但是当我尝试输入等于0.1或99.99我将无法工作的值时,我会收到这些错误
For 0.1 : Ensure this value is greater than or equal to 0.1.
For 99.99 : Ensure this value is less than or equal to 99.99.
我该如何将这些也包含在限制中?
我正在尝试发出POST请求但是收到此错误:
Traceback (most recent call last):
File "demo.py", line 7, in <module>
r = requests.post(url, data=payload, headers=headers)
File "/usr/local/lib/python2.7/dist-packages/requests/api.py", line 87, in post
return request('post', url, data=data, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/api.py", line 44, in request
return session.request(method=method, url=url, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 266, in request
prep = req.prepare()
File "/usr/local/lib/python2.7/dist-packages/requests/models.py", line 215, in prepare
p.prepare_body(self.data, self.files)
File "/usr/local/lib/python2.7/dist-packages/requests/models.py", line 338, in prepare_body
body = self._encode_params(data)
File "/usr/local/lib/python2.7/dist-packages/requests/models.py", line 74, in _encode_params
for k, vs in to_key_val_list(data):
ValueError: too many values to …Run Code Online (Sandbox Code Playgroud) 我有一个DeleteView.其中我想访问相关的对象ID.当用户发出POST请求时.
视图:
class DeletePacketView(LoginRequiredMixin, DeleteView):
model = Packet
template_name = DELETE_PACKET_TEMPLATE
def get_success_url(self):
# Return to customer home
return reverse('myapp:view_customer',
kwargs={'pk': self.object.customer.id
}
)
def post(self, request, *args, **kwargs):
html = """
<html>
<head>
<script>window.onunload = refreshParent; function refreshParent() {
window.opener.location.href=%s;
}
</script>
</head>
<body>
<h1>object deleted successfully</h1>
<button type="button" onclick="window.close()">OK</button>
</body>
</html>
""" % reverse('myapp:view_customer',
kwargs={'pk': self.object.customer.id
}
)
super(DeletePacketView, self).post(request, *args, **kwargs)
return HttpResponse(html)
Run Code Online (Sandbox Code Playgroud)
但是当我尝试提交表单时,我收到错误.
追溯:
Environment:
Request Method: POST
Request URL: http://localhost:8000/delete/packet/96/
Django Version: 1.7
Python Version: …Run Code Online (Sandbox Code Playgroud) python ×7
django ×4
scrapy ×3
scrapyd ×2
css ×1
csv ×1
django-forms ×1
django-views ×1
file-upload ×1
html ×1
javascript ×1
jquery ×1
progress-bar ×1
regex ×1