开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜