scrapy/nginx 服务带有http 验证,怎样使用curl 请求详解程序员
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
服务器部署程序员系统优化网站设置运维相关文章
- Scrapy框架
- scrapy爬虫完整的代码实例[通俗易懂]
- scrapy爬虫案例_Python爬虫 | 一条高效的学习路径
- python3+Scrapy爬虫实战(一)—— 初识Scrapy
- Python使用Scrapy爬取小米首页的部分商品名称、价格、以及图片地址并持久化保存到MySql中
- 使用 Scrapy + Selenium 爬取动态渲染的页面
- 状态Linux查看Nginx服务状态的简单方法(linux查看nginx)
- Scraping Web Data with Linux and Scrapy(linuxscrapy)
- 检查Linux下Nginx服务是否已启动(linux查看nginx是否启动)
- 服务如何在Linux中删除Nginx服务(linux删除nginx)
- 利用ScrapyRedis实现海量数据分布式爬取(scrapy-redis)
- Python爬虫框架Scrapy安装使用步骤