The website will include code that starts with name and ends with value with double quote.
Code: Select all
<div style="display:none;">
something="somethig"
categoryNo="[numbers]"
</div>
Here is the code that I made to get [numbers].
Code: Select all
SETLOCAL ENABLEDELAYEDEXPANSION
:: some commands..
:: curl path is !curl_p!
IF "!URL!" == "!URL:PostView.com?=!" IF "!URL!" == "!URL:PostList.com?=!" (
IF DEFINED URL_logNo (
ECHO ERROR
CALL :ERROR
EXIT /B
)
FOR /F %%A IN ('"!cURL_p!\curl.exe" -s https://url.com ^| "!NCA_P!\sed.exe" -n "s/^categoryNo=.\([0-9]\+\).$/\1/p"') DO SET URL_categoryNo=%%A
)
Code: Select all
:: this code will excute: "!cURL_p!\curl.exe" -s https://url.com | "!NCA_P!\sed.exe" -n "s/^categoryNo=.\([0-9]\+\).$/\1/p"
IF . EQU . (FOR /F %%A IN ('"!cURL_p!\curl.exe" -s https://url.com ^| "!NCA_P!\sed.exe" -n "s/^categoryNo=.\([0-9]\+\).$/\1/p"') DO SET URL_categoryNo=%%A)
options for sed below should also be enclosed in double quote.
But For /f that starts/ends with double quote will not work as expected.
Code: Select all
IF . EQU . (FOR /F %%A IN ('!cURL_p!\curl.exe -s https://url.com ^| "!NCA_P!\sed.exe" -n "s/^categoryNo=.\([0-9]\+\).$/\1/p"') DO SET URL_categoryNo=%%A)
Code: Select all
IF . EQU . (FOR /F %%A IN ('""!cURL_p!\curl.exe" -s https://url.com | "!NCA_P!\sed.exe" -n "s/^categoryNo=.\([0-9]\+\).$/\1/p""') DO SET URL_categoryNo=%%A)
Using CMD /C or moving to curl path is a not bad way, but I don't want to modify this code as much as possible.
Is there a simple way to use For /f that starts and ends with double quotes?