zl程序教程

您现在的位置是:首页 >  后端

当前栏目

scrapy/nginx 服务带有http 验证,怎样使用curl 请求详解程序员

scrapy服务NginxHTTP程序员 使用 详解 验证
2023-06-13 09:19:55 时间
爬虫服务免不了需要定时启动,就需要crontab+curl 来触发,但是curl 怎样发送带验证的请求.
有些网域需要 HTTP 认证,这时 curl 需要用到 --user 或者 -u 参数。 

$ curl --user name:password example.com 

如果不使用验证直接请求网站会有如下提示:
 html 

 head title 401 Authorization Required /title /head 

 body bgcolor="white" 

 center h1 401 Authorization Required /h1 /center 

 hr center nginx/1.14.0 (Ubuntu) /center 

 /body 

 /html 

使用验证了以后就没有问题:

curl --user user:password abc.com:6800

 html 

 head title Scrapyd /title /head 

 body 

 h1 Scrapyd /h1 

 p Available projects: b scrapy_rere /b /p 

 li a href="/jobs" Jobs /a /li 

 li a href="/items/" Items /a /li 

 li a href="/logs/" Logs /a /li 

 li a href="http://scrapyd.readthedocs.org/en/latest/" Documentation /a /li 

 /ul 

 h2 How to schedule a spider? /h2 

 p To schedule a spider you need to use the API (this web UI is only for 

monitoring) /p 

 p Example using a href="http://curl.haxx.se/" curl /a : /p 

 p code curl http://localhost:6800/schedule.json -d project=default -d spider=somespider /code /p 

 p For more information about the API, see the a href="http://scrapyd.readthedocs.org/en/latest/" Scrapyd documentation /a /p 

 /body 

 /html 

补充说明:

我的scrapy 服务是使用docker搭建的,docker中又使用nginx 代理验证,

原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/1578.html

服务器部署程序员系统优化网站设置运维