DosTips.com

A Forum all about DOS Batch
It is currently 03 Dec 2016 11:39

All times are UTC-06:00




Post new topic  Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Call fails
PostPosted: 15 Jun 2012 10:30 
Offline

Joined: 15 Feb 2012 14:02
Posts: 174
What is wrong with Call here? When I call the subroutine :download, help is printed.

Code: Select all
@echo off 
Setlocal EnableDelayedExpansion
SET proxy=Proxy.htm
SET proxy_2=Proxy_1.htm         

SET source_1=http://www.samair.ru/proxy
SET source_2=http://www.proxynova.com/proxy-server-list/


CHCP 1250 > NUL

for /f "delims=" %%x in (delimiter.ini) do set TAB=%%x
 
if not exist %proxy% (
  echo File not found
  pause
  exit
)

REM http://www.samair.ru/proxy/
FOR /F "tokens=7,12,15 delims=<>" %%A IN ('grep -B 25 "</td></tr></tbody></table>" %proxy% ^| grep high') DO ( echo %%B %%A %%C  )

pause

Echo Gonna download from proxynova.com
FOR %%N IN (1,2,3,4,5,6,7,8,9,10) DO CALL :download http://www.proxynova.com/proxy-server-list/?p=%%N

pause

REM one more loop to add .. FOR .. IN dir proxy_*
REM http://www.proxynova.com/proxy-server-list/
FOR /F "tokens=3,4,5 delims=<>" %%A IN ('grep -B 810 -E "<th colspan=.10.>&nbsp;</th>" %proxy_2% ^| grep -E ^"row_proxy^|port^|country^|proxy_^" ') DO (
  if "%%C" == "/span" SET ip=%%B
  if "%%C" == "/a" SET port=%%B
  if "%%B" == "/a" SET location=%%A
  if "%%B" == "/span" (
    SET A=%%A
    SET A=!A:"=$!
    FOR /F "tokens=1,2,3 delims=$ " %%S IN ("!A!") DO (
    SET type=%%U
    SET ready=1
    )
  )
if !ready!==1 (
  echo IP:!ip!:!port! in !location! is !type!
  SET ready=0
  pause
)
)
exit /b

:download
echo %1
pause
SET user_agent="User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.8) Gecko/20100214 Ubuntu/9.10 (karmic) Firefox/3.5.8"
SET accept="Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
SET accept_language="Accept-Language: en-us,en;q=0.5"
SET accept_charset="Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7"
SET keep_alive="Keep-Alive: 300"
SET connection="Connection: keep-alive"
SET url=http://request.urih.com/
del proxy_%1.htm
REM curl -o proxy_%1.htm -H %user_agent% -H %accept% -H %accept_language% -H %accept_charset% -H %keep_alive% -H %connection% %1
pause
GOTO :eof


Last edited by doscode on 15 Jun 2012 11:55, edited 1 time in total.

Top
   
 Post subject: Re: Call fails
PostPosted: 15 Jun 2012 10:56 
Offline
Expert

Joined: 23 Dec 2011 13:59
Posts: 3364
You need to put Quotes around the variable you are passing to the download function.
Code: Select all
FOR %%N IN (1,2,3,4,5,6,7,8,9,10) DO CALL :download "http://www.proxynova.com/proxy-server-list/?p=%%N"


You know there is such thing as a FOR /L loop.


Top
   
 Post subject: Re: Call fails
PostPosted: 15 Jun 2012 12:21 
Offline

Joined: 15 Feb 2012 14:02
Posts: 174
Thanks. This looks great now:

Code: Select all
@echo off 
Setlocal EnableDelayedExpansion
SET proxy=Proxy.htm
SET proxy_2=Proxy_1.htm         

SET source_1=http://www.samair.ru/proxy
SET source_2=http://www.proxynova.com/proxy-server-list/

for /f "delims=" %%x in (delimiter.ini) do set TAB=%%x
 
if not exist %proxy% (
  echo Soubor s proxy servery nenalezen! Konec.
  pause
  exit
)

REM http://www.samair.ru/proxy/
FOR /F "tokens=7,12,15 delims=<>" %%A IN ('grep -B 25 "</td></tr></tbody></table>" %proxy% ^| grep high') DO ( echo %%B %%A %%C  )

FOR /L %%N IN (1,+1,10) DO CALL :download "http://www.proxynova.com/proxy-server-list/?p=%%N" %%N

pause

REM http://www.proxynova.com/proxy-server-list/
FOR %%Z IN (proxy_*.htm) DO (
FOR /F "tokens=3,4,5 delims=<>" %%A IN ('grep -B 810 -E "<th colspan=.10.>&nbsp;</th>" %proxy_2% ^| grep -E ^"row_proxy^|port^|country^|proxy_^" ') DO (
  if "%%C" == "/span" SET ip=%%B
  if "%%C" == "/a" SET port=%%B
  if "%%B" == "/a" SET location=%%A
  if "%%B" == "/span" (
    SET A=%%A
    SET A=!A:"=$!
    FOR /F "tokens=1,2,3 delims=$ " %%S IN ("!A!") DO (
    SET type=%%U
    SET ready=1
    )
  )
if !ready!==1 (
  echo IP:!ip!:!port! in !location! is !type!
  SET ready=0
)
)
)
exit /b

:download
SET user_agent="User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.8) Gecko/20100214 Ubuntu/9.10 (karmic) Firefox/3.5.8"
SET accept="Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
SET accept_language="Accept-Language: en-us,en;q=0.5"
SET accept_charset="Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7"
SET keep_alive="Keep-Alive: 300"
SET connection="Connection: keep-alive"
SET url=http://request.urih.com/
del %1 2>NUL
Echo Gonna download from proxynova.com
curl -o proxy_%2.htm -H %user_agent% -H %accept% -H %accept_language% -H %accept_charset% -H %keep_alive% -H %connection% %~1
GOTO :eof


I have one more site which I want to proceed but this one is a little bit harder than the previous ones. There is very confusing the part of tags with IP
http://www.hidemyass.com/proxy-list/


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 3 posts ] 

All times are UTC-06:00


Who is online

Users browsing this forum: Yahoo [Bot] and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Limited