Public Class DownloadFileThread
<DllImport("urlmon.dll", CallingConvention:=CallingConvention.StdCall, CharSet:=CharSet.Unicode, EntryPoint:="URLDownloadToFileW", ExactSpelling:=True, SetLastError:=True)>
Public Shared Function urldownloadtofile(ByVal pCaller As Integer, ByVal szurl As String, ByVal szfilename As String, ByVal reserved As Integer, ByVal callback As Integer) As Integer
End Function
End Class
WebBrowser1.Naviagte("https://drive.google.com/uc?id=각자 파일마다 다르니 참고&export=download")
'공유 링크가 아니라 공유 링크에서 다운로드 버튼을 눌렀을 때 링크를 넣으셔야 합니다.
Dim strRes as string = WebBrowser1.Document.Body.InnerHtml
'strRes 변수에 HTML 소스 집어넣기
Dim strHTML as string = Split(Split(Split(strRes, "uc-name-size")(1), """>")(1), "</A>")(0)
'파일명을 strHTML 변수에 값을 담아준다.
strRes = "https://drive.google.com/uc?export=download&confirm="& Split(Split(strRes, "confirm=")(1), "&")(0) & "&id=각자 파일마다 다르니 참고"
'Confirm 값은 항상 바뀌어서 파싱으로 값을 가져옵니다.
DownloadFileThread.urldownloadtofile(0, strRes, Application.StartupPath & "\" & strHTML, 0, 0)
'파일 다운로드를 진행할 때 사용하는 코드입니다.
'strRes = 파일 주소
'Application.StartupPath & "\" & strHTMl = 파일을 실행시킨 경로에 파일을 다운로드한다.
구글 드라이브에서 용량이 어느 정도 있는 파일을 다운로드하려면 웹 세션을 유지시켜줘야 한다.
'프로그래밍 > VB.NET' 카테고리의 다른 글
[VB.NET] 리스트 뷰 서브 아이템 글씨 색 변경 (0) | 2022.05.25 |
---|---|
[VB.NET] 리스트 뷰 비교 (0) | 2022.05.25 |
[VB.NET] 폰트가 있는지 확인 후 폰트가 없다면 폰트 설치 (0) | 2022.05.25 |
[VB.NET] 리스트에 있는 아이템을 CSV 파일로 저장하기 (0) | 2022.05.25 |
[VB.NET] 리스트에 있는 아이템을 텍스트 파일(txt)로 저장하기 (0) | 2022.05.25 |