M
M
Mnobody2013-11-19 02:53:28
PHP
Mnobody, 2013-11-19 02:53:28

Internet bot. Why is it impossible to implement downloading with "redirection"?

I am writing a bot in php, among other things, it must log in (I use cURL) and download files. You can download only when the user (or bot) is authorized. Authorization turned out to be done, but there is no download.
With a "redirect" - no entry on your server. Toist immediately give to the user.

I send a POST request to the server with the necessary data (fileId and VerificationToken which are in the html code of the page). It returns json to me in which there is a link to the redirect (if you download normally in the browser, then the download starts automatically).

JSON
  redirectUrl=http://s5905.somesite.pl/File.aspx?e=dlinnyj_hasz_kod
  refreshTopBar=False
  topBar=<div class="topbarLoginContainer"> html контейнера для авторизации, также 2 ссылки на картинки, но картинки больше чем 1х1</div>
  trackingCodeJS=_gaq.push(['ch._trackEvent', 'Files', 'Download', 'Download_File']);
  Type=Redirect


I get a link to the redirect from there, I give it out via echo link .
When I try to follow the link, I get:
Object moved to <a href="/Error.aspx?aspxerrorpath=/File.aspx">here</a>.

And it gives a 302 found error.

The condition is that you can not download to the server and then give it away, but give it right away from the source server.

What ideas? What did I miss? What could be the problem?

Digression: People, do not use fonts in which I (large and) is similar to l (l). The first time I read field instead of fileId and a couple of hours went nowhere.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
Mnobody, 2013-11-19
@Mnobody

Successful download. Mainly due to the fact that the site is poorly protected.
I just did not notice the \u0026 character in the long hash code of the response (json format), which in the subsequent get request must be replaced with &. Thus, two parameters will be sent and not one, as I did before.

W
Webdesus, 2013-11-19
@Webdesus

This is hardly possible. If you just try to save cookies additionally and not just throw a link, but also implement saved cookies. Then if the site keeps the session for a long time per file, then it will be possible to download. No, well, then it's not realistic in this condition. After all, when you click on a link, you are already a completely different client for the site, not the one who requested the link for the first time. Accordingly, this is the result.

A
Anton, 2013-11-19
@sHinE

As far as I remember, from the experience of picking php-proxy, I can say that through curl it was only possible to save the content of the file into a variable, and then display it to the user. The file size is limited by the memory available for php.
When using sockets, you can stream download - i.e. read part of the file - gave it to the client. Here http://sourceforge.net/projects/poxy/ you can see the principle.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question