-
Mar 1st, 2024, 02:13 PM
#1
Thread Starter
Junior Member
VB6 'XML' Receive file name (unknown) from an url address
Hello, I hope you explain it well, I have a problem receiving the name of a file by entering a URL address.
I don't understand the XML language much, although I found a code that received with the 'status' command if the file existed, now I want to know by putting an address of any server which name of the file is behind that address.
Example: the address I send is:
https://server/tgha3ynvylrx1g434
File name behind this address is:
FileDown.rar
My problem question is, if I sent this URL address, the response would be the name of the file and what would be the command to receive said response.
-------Find code in VB6-------------------------
Dim sUrl as string
url="https://server/tgha3ynvylrx1g434"
xmlhttp.open "GET", sUrl, False ' "GET", sUrl, False 'GET
xmlhttp.setRequestHeader "Content-Type", "application/xml"
xmlhttp.send ""
If xmlhttp.Status = 200 Then
Msgbox "YES"
Else
Msgbox "NO"
End If
Set xmlhttp = Nothing
---------------------------------------------------
This is the code, although it returns all the code in xml with the file name.
But it is impossible for me since the texts sent on different servers are varied with different characters and I cannot capture the name of the file, I hope I have explained myself. Thank you.
-
Mar 1st, 2024, 02:18 PM
#2
Fanatic Member
Re: VB6 'XML' Receive file name (unknown) from an url address
Assumedly this is a protection against exactly what you are trying to do, and it isn't impossible to do but it is unlikely you will get much help here with the parsing problem.
One thing I will say is that, with time and effort, you can find fallback values that can be parsed for so that over time you will get all the potential data that you need. That said, you say you're receiving a file name...assumedly with the full URL...if you know the start of the URL and assumedly it doesn't change then surely you could parse using that as your target? There HAS to be something unique across all returned results.
-
Mar 1st, 2024, 03:53 PM
#3
Thread Starter
Junior Member
Re: VB6 'XML' Receive file name (unknown) from an url address
Hello, thank you for responding, once you have received the entire URL code in XML, here are the different results received on different servers.
-------------------------------------------------- ----
<input type="hidden" name="fname" value="xxxxxx.part01.rar">
<td class="normal">xxxxxx.part01.rar</td>
<span title="xxxxxx.part01.rar">
-------------------------------------------------- ---
As you can see, the only references are ".rar" and " at the beginning.
I am using the MID(),InStrRev() and InStr() functions to capture the file, but it fails to locate "it depends on sending the code.
I don't know how download programs like 'JDonloader' or 'Mipony' do it.
I don't know what solution there is or if it can be done in a different way...?
Thank you
-
Mar 4th, 2024, 12:39 PM
#4
Thread Starter
Junior Member
Re: VB6 'XML' Receive file name (unknown) from an url address
Hello, more or less solved the problem of obtaining the name of the file with a URL address without the name of the file to download by obtaining the XML code.
Now I see that there are addresses obtaining their XML code, they do not provide the name of the file to download.
But when you paste that address into a browser and load the page, the name of the file appears.
I really don't know how to do this step, let's see if someone can help me with the issue.
Thank you
-
Mar 4th, 2024, 01:10 PM
#5
Fanatic Member
Re: VB6 'XML' Receive file name (unknown) from an url address
If they have addressed the issue of you obtaining the XML, they're actively fighting it...at this point you're asking us to participate in abusing a website's security...which is against the TOS for this site.
That said, you've already said that the file is always RAR so why isn't parsing for a ".rar" possible? if it is sometimes .zip, having a fallback for that works. You can look at the character following the .rar to work out whether to InstrRev for " or >...you essentially have all you need to work it out yourself.
If InStr(SourceHTML, ".rar") > 0 then suffix=".rar"
if InStr(SourceHTML, ".zip") >0 then suffix=".zip"
That gets you the suffix of the file, then you can instr for the suffix (again) and do what is needed to work out the format required to pull the data out.
If you are saying that it no longer lets you get the filename from the link, you're probably on your own unless we knew the website in question...you may find setting up a HTTP client through winsock helps with this problem as it will pretend to be a specific browser and will request the page, and you will get a response from the server with more details (probably a redirect, is my guess) and you may have to follow that redirect within the HTTP client to get the information you need. You're on your own with exactly how to do this though, for reasons explained at the top of this reply.
-
Mar 5th, 2024, 04:07 AM
#6
Thread Starter
Junior Member
Re: VB6 'XML' Receive file name (unknown) from an url address
Hello, it seems to me that you have misinterpreted what I have written previously.
The only thing I want, that when sending the request by XML code, is to only obtain the name of the file, not download it, it is as if I send the request, if the file exists, the server would send me a response like '200 ok' in XML.
Anyway, as I said before, these programs 'JDoanloader, Mipony etc...' are capable of supplying the file name and that is what I want.
Here I leave two pieces of XML that the server sends me, one contains the name of the file and the other does not.
'----------- NAME FILE XML CONTAINS ----------------------------------------------------------
<span class="spacer spacer-20"></span>
<div id="awn-z2285595" style="padding-left:30px;padding-right:30px;max-width:1000px;margin:auto"></div>
<span class="spacer spacer-20"></span>
<table class="premium" style="width:900px;margin:10px auto" cellspacing="4">
<tr>
<td style="width:150px" rowspan="3" ><img style="vertical-align:middle" src="https://1fichier.com/qr.pl?do=0.tv7a3ynvylrx1g4mjjyi&s=1" width="148" height="148" /></td>
<td class="titre normal" style="width:180px">filename :</td>
<td class="normal">v1daspas4das.part01.rar</td>
</tr>
<tr><td class="titre normal">date :</td><td class="normal">21/02/2024</td></tr>
<tr><td class="titre normal">size :</td><td class="normal">975.07 mb</td></tr>
</table>
--------- NO FILE NAME CONTAINS ------------------------------------------------------
<!doctype html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta property="og:title" content="960 mb file on mega" />
<meta property="og:url" content="https://mega.nz/file/hhw2kq4b" />
<meta property="og:image" content="https://mega.nz/rich-file.png" />
<meta property="twitter:card" content="summary" />
<meta property="twitter:title" content="960 mb file on mega" />
<meta property="twitter:url" content="https://mega.nz/file/hhw2kq4b" />
<meta property="twitter:image" content="https://mega.nz/rich-file.png" />
<meta http-equiv="x-ua-compatible" content="ie=edge" />
<meta http-equiv="content-type" content="text/html, charset=utf-8" />
<meta name="referrer" content="strict-origin-when-cross-origin" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"/>
<meta name="google" value="notranslate" />
<link rel="icon" href="/favicon.ico?v=3" type="image/x-icon" />
<link rel="chrome-webstore-item" href="https://chrome.google.com/webstore/detail/bigefpfhnfcobdlfbedofhhaibnlghod" />
</head>
<body id="bodyel" class="theme-light not-logged">
<script type="text/javascript" src="/secureboot.js?r=1709160602" charset="utf-8"></script>
<div id="overlay" style="display:none; width:100%; height:100%; position:absolute; left:0px; right:0px; cursor:wait; z-index:999999;"></div>
<div class="download-overlay" id="download_overlay" style="display:none;"></div>
<div class="nav-overlay hidden"></div>
<div id="pageholder" style="display:none;"></div>
<div id="mainlayout" class="main-layout no-tablet-layout">
<div id="startholder" class="fmholder"></div>
<div id="fmholder" class="fmholder" style="display:none;"></div>
</div>
<a href="" download="filename" id="dllink" style="display:none;"></a>
<div style="position:absolute;" id="startswfdiv"></div>
<div id="tooltip"></div>
<div style="position:absolute; left:0px; width:100%; top:0px; height:60px; z-index:99; display:none;" id="topmenufm">
</div>
<textarea id="chromeclipboard" title="copy" style="position:absolute;top:-100%;left:-100%;opacity:0" readonly></textarea>
<iframe id="i-ping" style="position:absolute;top:-100%;left:-100%;opacity:0;display:none" src="about:blank"></iframe>
</body>
</html>
--------------------------------------------------------------------------------------------------------------------------------------------------------
I don't know if in the request command I use:
xmlhttp.setRequestHeader "Content-Type", "application/xml"
Something else can be changed, with a more specific or more powerful command.
'-------SIMPLE CODE VB6, XML ----------------------------------------------
Function UrlPost(stextUrl As String) As Boolean
'Contact the server to verify if the file exists and one of the responses is '200 Ok'
'Loaded 'Microsot XML, v6.0' library
Dim xmlhttp As MSXML2.ServerXMLHTTP60
Set xmlhttp = New MSXML2.ServerXMLHTTP60
xmlhttp.open "GET", stextUrl , False
xmlhttp.setRequestHeader "Content-Type", "application/xml"
xmlhttp.send ""
Text1.text = LCase(xmlhttp.responseText)
If xmlhttp.Status = 200 Then
UrlPost = True
Else
UrlPost = False
End If
Set xmlhttp = Nothing
Exit Function
'---------------------------------------------------------------------------------------
Thank you.
Last edited by Lompin; Mar 5th, 2024 at 05:09 AM.
-
Mar 5th, 2024, 05:23 AM
#7
Fanatic Member
Re: VB6 'XML' Receive file name (unknown) from an url address
JDownloader and similar apps will do what I suggested above, follow the URL path until the point that they get a name in response...even if the file send initiates, it can be stopped after only a few bytes has been sent, and you SHOULD get your file data (name, and size if the server has sent it...not all of them do). At the very least, looking for a > that isn't followed by a < would give you potential locations for the filename that you could compare against a set of rules (all alphanumeric or . with no illegal characters like , or : as an example) to see if it might be a filename...or, if it is always a RAR, just do an instr() for .rar and if it doesn't find anything then keep looking manually for links to follow that might offer the data you need...you need to find something that you can programmatically automate later, which shouldn't be difficult.
It's been a LONG time since I worked with HTTP to this degree, and having to handle HTTP redirects and such...all I can do is point you in a possible direction (it may not even be the best direction to go). Just be glad you're not working with sites that use javascript obfuscation or on-demand loading of extra HTML and the like, as they are pains to bypass unless you have the right code in place to handle everything.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|