Consider 3 things:
1) Python is not my thing
2) If I understand the question
3) If that’s correct: os.environ['_data'] = 'date'
4) At this link if the most correct is:
import os
name = os.environ.get(_name)
data = os.environ.get(_data)
start_urls = os.environ.get(_start_urls)
I’ve done a couple of exchanges of variables between the Bats and Fortran.
I think you have to add some lines in the/python script to read the items
processed in bat input, what is commented in the code here published.
@echo off & mode 60,9 & color 0a && setlocal enableextensions enabledelayedexpansion
break off && set "_cnt=0"& call :_banner_screen
for /l %%l in (1 2 60) do (
ping -n 1 127.0.0.0 2>nul >nul && cls & echo/!_double_line!
if %%l neq 60 (
echo/!_underl:~-%%l!&& echo/!_banner:~-%%l!&& echo/!_underl:~-%%l!
echo/ & echo/ &echo/!_double_line!
) else (
echo/!_underl:~-%%l!&& echo/!_banner!&& echo/!_underl:~-%%l!
)
)
set /p "_input_data= Insira uma data no formato 'DD/MM/AAAA:"
for /f %%c in ('cmd /u /c set /p "=%_input_data:"= %"^<nul^|find /v /c ""') do call set /a _cnt=%%c + 0
if "!_input_data:~0,2!" leq "0" set _error=on
if "!_input_data:~0,2!" gtr "31" set _error=on
if "!_input_data:~3,2!" leq "0" set _error=on
if "!_input_data:~3,2!" gtr "12" set _error=on
if "!_input_data:~6,4!" leq "2002" set _error=on
if "!_input_data:~6,4!" gtr "!date:~6,4!" set _error=on
if not "!_cnt!" equ "10" (
echo/& echo/ # E R R O : Data informada esta errada: !_input_data!
goto :_eof
) else if /i "!_error!"=="on" (
echo/& echo/ # E R R O : Data informada esta errada: !_input_data!
)
echo/!_input_data!| findstr /l /c:"\/" && set _input_data=!_input_data:/=-!
echo/!_input_data!| findstr /l /c:"\\\" && set _input_data=!_input_data:/=-!
)
)
set _data=!_input_data!
set _name=imprensa_Nacional
set _start_urls=[http://www.imprensanacional.gov.br/leiturajornal^?data=!_data!^&secao^=dou3]
cls && mode 82,9 && echo/!data! & echo/!name! & echo/!start_urls!
echo/ No script python, adicione esses itens:
echo/ ----------------------------------------
echo/ os.environ['_data'] = 'data'
echo/ os.environ['_name'] = 'name'
echo/ os.environ['_start_urls'] = 'start_urls'
timeout /t 10 >nul
if exist "C:\Users\Jonathan Pereira\Desktop\ProjetoIruan\Robos\Aranhas\spiders\scrapy.*" (
pusd "C:\Users\Jonathan Pereira\Desktop\ProjetoIruan\Robos\Aranhas\spiders"
.\scrapy crawl imprensa_Nacional -o imprensa_Nacional.csv -s CSV_DELIMITER=";"
popd
)
goto :_eof
:_banner_screen
(
set _double_line=^
set _double_line=!_double_line!^!_double_line!
set "_underl= _________________________________________________________"
set _banner=^
__________* I M P R E N S A * N A C I O N A L *__________
break on && exit /b
)
:_eof
Try quotation marks on the path "C: Users Jonathan Pereira Desktop Projetoiruan Robos Spiders Spiders"
– Wictor Chaves
It didn’t work to do with ""
– Jonathan Igor Bockorny Pereira
You are trying to run as an administrator?
– Wictor Chaves
Error when running bat?
– nosklo