cURL์ ๋ฆฌ๋ ์ค์ ๋งฅ ํฐ๋ฏธ๋์์ HTTP ์์ฒญ์ ์ํํด๋ณด๊ธฐ ์ํด์ ๋ง์ด ์ฌ์ฉ๋๋ค. ์๋์ฐ์์๋ ๋ง์ดํฌ๋ก์ํํธ์์ ์ ๊ณตํ๋ ์ปฌ ํ๋ก๊ทธ๋จ์ด ๋ด์ฅ๋์ด์๋ค. ๊ทธ๋์ ๋ช ๋ น ํ๋กฌํํธ(cmd)๋ก curl ๋ช ๋ น์ด๋ฅผ ์ํํด๋ณด๋ฉด ์๋์ ๊ฐ์ด ์ ์์ ์ผ๋ก ์ฌ์ฉํ ์ ์์์ ์ ์ ์๋ค. ํ์ง๋ง, ์๋์ฐ ํฐ๋ฏธ๋์์๋ ๋ช ๋ น ํ๋กฌํํธ๊ฐ ์๋๋ผ ํ์์(Powershll)์ ์ฌ์ฉํ๊ณ ์์ผ๋ฏ๋ก Invoke-WebRequest ์ผ๋ก ํธ์ถ๋์ด ๊ธฐ๋ณธ์ ์ผ๋ก ์๋ ๋ช ๋ น์ด๊ฐ ์ํ๋์ง ์๋๋ค.
C:\Users\Mambo>curl -V
curl 8.0.1 (Windows) libcurl/8.0.1 Schannel WinIDN
Release-Date: 2023-03-20
Protocols: dict file ftp ftps http https imap imaps pop3 pop3s smtp smtps telnet tftp
Features: AsynchDNS HSTS HTTPS-proxy IDN IPv6 Kerberos Largefile NTLM SPNEGO SSL SSPI threadsafe Unicode UnixSockets
PS C:\Users\Mambo> curl
cmdlet Invoke-WebRequest(๋ช
๋ น ํ์ดํ๋ผ์ธ ์์น 1)
๋ค์ ๋งค๊ฐ ๋ณ์์ ๋ํ ๊ฐ์ ์ ๊ณตํ์ญ์์ค.
Uri: okky.kr
StatusCode : 200
StatusDescription : OK
Content : <!DOCTYPE html><html lang="ko" class="js-focus-visible h-full"><head><meta charSet="utf-8"/><title>
OKKY - All That Developer</title><meta name="robots" content="index,follow"/><meta name="descriptio
n"...
RawContent : HTTP/1.1 200 OK
Transfer-Encoding: chunked
Connection: keep-alive
Vary: Accept-Encoding
Cache-Control: private, no-cache, no-store, max-age=0, must-revalidate
Content-Type: text/html; charset=utf...
Forms : {}
Headers : {[Transfer-Encoding, chunked], [Connection, keep-alive], [Vary, Accept-Encoding], [Cache-Control, p
rivate, no-cache, no-store, max-age=0, must-revalidate]...}
Images : {}
InputFields : {}
Links : {}
ParsedHtml : mshtml.HTMLDocumentClass
RawContentLength : 22832
cURL์ curl shipped by Microsoft ๋ฌธ์๋ฅผ ์ฐธ๊ณ ํด๋ณด๋ฉด Powershell Alias์ ๋ํ ๋ฌธ์ ๋ก ์ธํด curl.exe ๋ก ํ๋ก๊ทธ๋จ์ ์ง์ ํ์ฌ ๋ช ๋ น์ด๋ฅผ ์ํํ๋๋ก ์๋ดํ๋ค.
PS C:\Users\Mambo> curl.exe -V
curl 8.0.1 (Windows) libcurl/8.0.1 Schannel WinIDN
Release-Date: 2023-03-20
Protocols: dict file ftp ftps http https imap imaps pop3 pop3s smtp smtps telnet tftp
Features: AsynchDNS HSTS HTTPS-proxy IDN IPv6 Kerberos Largefile NTLM SPNEGO SSL SSPI threadsafe Unicode UnixSockets
ํ์์ Alias ์ ๊ฑฐํ๊ธฐ โ
Remove-Item ๋ช ๋ น์ด๋ก Alias๋ฅผ ์ ๊ฑฐํ ์ ์์ผ๋ฉฐ ๋ช ๋ น์ด๋ฅผ ์คํํ๊ณ ๋์ ์ํ๋ฅผ ์ ์งํ ์ ์๋๋ก ํ์ฌ ํ๋กํ์ผ์ ๋ฉ๋ชจ์ฅ์ผ๋ก ์ด์ด curl์ ๋ํ Alias๋ฅผ ์ญ์ ํ ์ ์๋๋ก ์ฝ๋๋ฅผ ์์ฑํ์ฌ ์ ์ฅํ๋๋ก ํ์. ์ด์ ๋ ๊ตณ์ด curl.exe ๋ผ๋ ํ๋ก๊ทธ๋จ์ ์ง์ ํด์ ํธ์ถํ ํ์๊ฐ ์์ด์ง๋ค.
PS C:\Users\Mambo> remove-item alias:\curl
PS C:\Users\Mambo> curl -V
curl 8.0.1 (Windows) libcurl/8.0.1 Schannel WinIDN
Release-Date: 2023-03-20
Protocols: dict file ftp ftps http https imap imaps pop3 pop3s smtp smtps telnet tftp
Features: AsynchDNS HSTS HTTPS-proxy IDN IPv6 Kerberos Largefile NTLM SPNEGO SSL SSPI threadsafe Unicode UnixSockets
notepad $profile
# ๋ฉ๋ชจ์ฅ ์๋จ์ ์
๋ ฅ
if (Test-Path -Path alias:curl) { Remove-Item alias:curl }
[ํ] ๋ฆฌ๋ ์ค์์ cURL ๋ช ๋ น์ด ์ถ๋ ฅ์ด ๊ฐํ๋์ง ์์ ๊ฒฝ์ฐ โ
๊ฐํน ๋ฆฌ๋ ์ค์์ cURL ๋ช ๋ น์ด๋ฅผ ์ํํ๋ฉด ์ถ๋ ฅ ๊ฒฐ๊ณผ๊ฐ ๊ฐํ๋์ง ์์์ ๋ค์ ๋ช ๋ น์ด๋ฅผ ํธ์ถํ ๋ ๋ถํธํจ์ ๋๋ ์ ์๋ค. https://stackoverflow.com/a/14614203์ ๋์์๋ ๊ฒ์ฒ๋ผ ์ฌ์ฉ์ ๋๋ ํ ๋ฆฌ์ .curlrc ํ์ผ์ ๋ง๋ค์ด์ ๊ฐํ์ด ๋์ํ๋๋ก ์์ฑํด๋๋ฉด ๋๋ค.
vi ~/.curlrc
-w "\n"