我尝试了以下方法:
import grequests
urls = ['http://localhost/test', 'http://localhost/test']
params = {'a':'b', 'c':'d'}
rs = (grequests.post(u, params) for u in urls)
grequests.map(rs)
Run Code Online (Sandbox Code Playgroud)
但它说如下:
File "search.py", line 6, in <genexpr>
rs = (grequests.post(u, params) for u in urls)
TypeError: __init__() takes exactly 3 arguments (4 given)
Run Code Online (Sandbox Code Playgroud)
我还需要将响应传递给回调进行处理.
我尝试了DER和PEM格式.我尝试使用文件扩展名crt,cer,p12,pem但没有导入它们.我进入设置>安全>从SD卡安装,它将我带到下载页面.我列出了证书,但是当我点击它们时,没有任何反应.
更新添加:我最终回到4.3.它工作得很好.
这就是我的蜘蛛的设置方式
class CustomSpider(CrawlSpider):
name = 'custombot'
allowed_domains = ['www.domain.com']
start_urls = ['http://www.domain.com/some-url']
rules = (
Rule(SgmlLinkExtractor(allow=r'.*?something/'), callback='do_stuff', follow=True),
)
def start_requests(self):
return Request('http://www.domain.com/some-other-url', callback=self.do_something_else)
Run Code Online (Sandbox Code Playgroud)
它转到/ some-other-url但不是/ some-url.这有什么不对?start_urls中指定的url是需要通过规则过滤器提取和发送的链接的url,其中start_requests中的url直接发送到项目解析器,因此不需要通过规则过滤器.
我在settings.py中有以下内容
ITEM_PIPELINES = ['mybot.pipelines.custompipeline']
Run Code Online (Sandbox Code Playgroud)
但是当我开始scrapy时,我收到以下警告.
/lib/python2.7/site-packages/scrapy/contrib/pipeline/ init .py:21:ScrapyDeprecationWarning:ITEM_PIPELINES定义为列表或集合已弃用,切换到dict类别= ScrapyDeprecationWarning,stacklevel = 1)
它似乎仍然正常工作.但是,为了删除此警告,我需要做什么?
我在start_urls中有一个URL
爬网程序第一次加载页面时,首先会显示403错误页面,然后爬网程序将关闭.
我需要做的是在该页面上填写验证码,然后让我访问该页面.我知道如何编写绕过验证码的代码,但是我将这些代码放在我的蜘蛛类中?
当遇到同样的问题时,我还需要在其他页面上添加它.
from scrapy.contrib.spiders import CrawlSpider, Rule
from scrapy.contrib.linkextractors.sgml import SgmlLinkExtractor
from scrapy.selector import Selector
class MySpider(CrawlSpider):
name = "myspider"
allowed_domains = ["mydomain.com"]
start_urls = ["http://mydomain.com/categories"]
handle_httpstatus_list = [403] #Where do I now add the captcha bypass code?
download_delay = 5
rules = [Rule(SgmlLinkExtractor(allow=()), callback='parse_item')]
def parse_item (self, response):
pass
Run Code Online (Sandbox Code Playgroud) 我有一个网站,我想从中提取数据.数据检索非常简单.
它使用HTTP POST获取参数并返回JSON对象.所以,我有一个我想要做的查询列表,然后以一定的间隔重复更新数据库.scrapy适合这个还是我应该使用其他东西?
我实际上不需要关注链接,但我确实需要同时发送多个请求.
我正在尝试抓取一个大型网站。他们有一个速率限制系统。遇到403页面可以暂停scrapy 10分钟吗?我知道我可以设置 DOWNLOAD_DELAY 但我注意到我可以通过设置一个小的 DOWNLOAD_DELAY 来加快抓取速度,然后在出现 403 时暂停抓取几分钟。这样速率限制只会每小时触发一次。