开发者

Java - How to programmatically download an attachment from a URL which opens a new tab?

开发者 https://www.devze.com 2023-02-13 10:04 出处:网络
I need to download an attachment from a URL (say http://mywebsite.com) programmatically using Java. The tricky part is that the above URL opens up a new tab/window onload from which the downloading ac

I need to download an attachment from a URL (say http://mywebsite.com) programmatically using Java. The tricky part is that the above URL opens up a new tab/window onload from which the downloading actually starts.

E.g.

  1. Open http://mywebsite.com
  2. http://mywebsite.com loads and 开发者_运维百科opens up a new tab to http://mywebsite.com/attachments/someRandomFileName.pdf

*Note the file name in step 2 (above) is randomly assigned so I cannot hit http://mywebsite.com/attachments/someRandomFileName.pdf directly.

Thanks in advance!


The whole point of randomly generated URLs is to prevent people to access content directly.

They probably want users to go through their web site to access the file. There are numerous ways to check that request is coming from a real user/browser. This includes executing javascript and/or flash. Random URLs are generated on server and at some point they will be sent to browser.

So basically, to download a file, you'd have to look at what their web site is doing, what kind of requests it is making and what replies it gets from servers. Then try to reverse engineer this to get directly to random URL representing the file.

0

精彩评论

暂无评论...
验证码 换一张
取 消