How to Automatically Click Hyperlinks in a Web Page? - javascript

There is a page with hundreds of hyperlinks, each hyperlink is displayed as a text "Download" as follows:
Download
Download
Download
Now we need to download all the scripts, but as you can see, there are many hyperlinks, and it will cost lots of time to click each hyperlink and then save the file one by one.
So we wonder if there is a quick way to download all the files, maybe using web-automation?
Do you have any suggestion or recommendation about the tools?
Thank you!

Use the extension downthemall on firefox https://www.downthemall.net/
this has what you need
please research more

Related

change input HTML in chrome automatically

is it possible in chrome when if am in specific website if it have input with type password it automatically change it to text ?
the purpose of this is because I always want to see the password I am typing.
thanks for helping
I recommend downloading the extension tampermonkey that allows you to run JavaScript code on all the pages you want.
You can then create your own script to do what you want, or take one from GitHub:
like this one that seems to do what you want:
https://gist.github.com/LouCypher/1870154
to download the script just click on the raw button on gist after installing the extension, tampermonkey will automatically recognise the script and propose you to download it.

Display PDF like on web

I am trying to display PDF file on the web without download option and copy option.
Then I found this https://books.google.co.in/books?id=kwBvDwAAQBAJ&printsec=frontcover&source=gbs_ge_summary_r&cad=0#v=onepage&q&f=false
Can you tell me how can I achieve this on my website?
What mplungjan said in his comment is correct. Anything that is put on the web can be copied one way or another. It appears that the google site you linked to is just showing an image of each page (see https://books.google.co.in/books/content?id=kwBvDwAAQBAJ&pg=PP1&img=1&zoom=3&hl=en&sig=ACfU3U0s8V3HjcApLeNwIGStMQlzZFaotA) with transparent pixels over each image to make it so you can't right-click to save the image. But it's easy to see what they're doing by viewing the source in the inspector.
If you don't want your users to be able to download the entire file, you could break it up into multiple small files (or images, like google is doing in your link) that would make it a little harder for them to get the files. But you can't really stop them from downloading anything.

Finding where links are

When I go to this webpage, I see green buttons with the text "信息公开". My task is to download all links of this green button. So if there are ten buttons, I need all ten links.
However I cannot find the text "信息公开" when I download the page in Chrome. I suspect that some Javascript is executed to download information related to "信息公开". Indeed, when I use Chrome to inspect the green buttons, I find information that I cannot find in the HTML files which I download.
How can I find out where the links are?
You have two JavaScript-based options:
a) Use a headless browser like Phantom.js to scrape the site for the links, there should be no problem with the JavaScript-loaded content. This would be the solution if you want to automate the scraping (like running it daily and posting the links somewhere)
b) Much simpler, but not as automatic: Use the jQuery in the Chrome Console to build a selector to get all the links. For example this piece of code, will give you the links of the yellow community box on the right side of Stack Overflow:
$('.community-bulletin a').each(function(){console.log($(this).attr('href'))})

Disable toolbar in PDF Web View Element to disable Download and Print

My issue is that I have to deploy a local server (without internet), so I cannot use Google Doc Viewer in this case. All I want is to restrict the user from download or printing the document. I have tried hiding or removing the toolbar in JS but it is not working out.
You may be able to disable the toolbar somehow, but that isn't good enough to keep users from downloading or printing it anyway, and nothing you can do will be. If a person can see something, they can copy it, no matter what you try to do to stop them (and all trying will do is inconvenience legitimate users). Previous similar questions:
How to prevent downloading images and video files from my website?
disable downloading of image from a html page
https://graphicdesign.stackexchange.com/questions/39462/is-it-possible-to-prevent-download-of-images-when-designing-a-website
Although those talk about images, the exact same reasoning applies to PDFs.

Prevent dowloading of files

I have made a small web page in which I have some modal windows (jquery.simplemodal). When those windows are showed they should display two pdf files ( downloaded from server ).
<div id="modal1"> - hiden modal window
<embed src="/FileDownload?id=100" width="100%" height="600px">
<embed src="/FileDownload?id=150" width="100%" height="600px">
</div>
<table>
<tr>
<td>
Modal Window 1
</td>
</tr>
</tale>
The problem I have is that when the page is loaded also is downloading all files from server.
From HTML point of view I had read that nothing is possible to do to avoid this.
Can you please tell me if is posible to do that with Javascript ( for example updating src's embed element when the modal window is first displayed )?
On http://stackoverflow.com I have found some topics about changing the properties of an element but nothing is working on me.
JavaScript: Changing src-attribute of a embed-tag
Can i open a modal window from file A and displaying file B on the modal window?
Thank you!
P.S. This is an Intranet application. I want just to avoid downloading 20-40 files (a few MB each ) every time the page is open. The other solution I am thinking is to use a Java applet but I think this would complicate this small project.
Using jQuery. I believe this is what you want to do: only load embed files if you click on the link which pops up the modal?
$("a").click( function (e) {
e.preventDefault();
$("#modal1").append("<embed id='100' src='/FileDownload?id=100' width='100%' height='600px'/><embed id='150' src='/FileDownload?id=100' width='100%' height='600px'/>");
$("#modal1").show();
});
And the Fiddle
The nature of Web browsers is to download files to a cache so that upon the next visit, or during page changes, display times are greatly reduced. As a web developer there is nothing you can do to prevent this. The user can turn this feature off in his own browser if he desires to keep his cache clean, but you and your site cannot. There are ways to impede a viewer from intentionally downloading an image or file such as disabling right clicks over an image, but there are ways for a savvy user to get around these methods as well.
PDF files especially need to be downloaded to speed up viewing. If this is turned off, the user experience will be so slow you will drive people away from your site.
Even if its impossible to completely protect your files, there are a few ways to make it harder to download your original PDF document, we have a few PHP scripts that may help you that you can find inside our desktop publisher (available in GPL and commercial).
Its free to download and you can grab the scripts even if you don't use the rest of the product. If you download it and as you publish your document you can expand advanced settings and tick "sign and obfuscate" and you should get the scripts necessary to protect your files.
http://flexpaper.devaldi.com/flexpaper_flip_zine.jsp

Categories