How to download a page from GET url using wget - download

I am trying to download the google search results page for Gop primaries results using wget but I am not able to do that (this page). But, I noticed that the webpage is getting the data from this file https://goo.gl/KPGSqS which it gets using a GET request.
So, I was wondering if there is a way to download that file with wget? The usual way i do is using wget -c url but that is not working. So, any ideas on what i should do for this?
I tried with the user-agent option, but even that isn't working.

If you want to download a webpage content (parsed to simple text file or source html code) you could consider using lynx. Download lynx by typing sudo apt-get lynx and then you could save the webpage content using lynx http://your.url/ > savefile.txt.
You can find how to use lynx in this page

Related

WGET - Download specific files (by extension or mime-type) from third party websites

I need to get ALL ".js" extension files from a website by using wget, including third party ones, but it's not always being done.
I use the next code:
wget -H -p -A "*.js" -e robots=off --no-check-certificate https://www.quantcast.com
For example, if I execute wget to "https://www.stackoverflow.com" I want to get all "*.js" files from stackoverflow.com but also third party websites, such as "scorecardresearch.com", "secure.quantserve.com" and others.
Is something missing in my code?
Thanks in advance!
Wget with the -p flag will only download simple page requirements like scripts with a src, links with an href or images with a src.
Third party scripts are often loaded dynamically using script snippets (such as Google Tag Manager https://developers.google.com/tag-manager/quickstart). These dynamically loaded script will not be downloaded by Wget, since they need to run the JavaScript to actually load. To get absolutely everything, you would likely need something like Pupeteer or Selenium to load the page and scrape the contents.

Download CSV file in bash shell

Hello friends I am trying to download a csv file from a external url I try with wget command but I obtain a 400 Error bad request if I paste the url directly in the browser I can download the csv file, is there another way to download this type of file or other solution? I need to have a file with the csv content.
Thanks
Have you escaped all special characters in the url such as & to \& or $ to \$
If it doesn't have to do anything with authentication/cookies, run some tool on your browser (like Live HTTP Headers) to capture headers. If you, then, mockup those fields in wget, that would get you very close to be like your "browser". That will also show you if there is any difference in encodings between wget data and browser data.
On other hand, you could also watch the server log files (if you have access to them).

how to get all chrome download links with wget command tool automatically?

I'm trying to download all the images that appear on the page with WGET, it seems that eveything is fine but the command is actually downloading only the first 6 images, and no more. I can't figure out why.
The command i used:
wget -nd -r -P . -A jpeg,jpg http://www.edpeers.com/2013/weddings/umbria wedding-photographer/
It's downloading only the first 6 images relevant of the page and all other stuff that i don't need, look at the page, any idea why it's only getting the first 6 relevant images?
Thanks in advance.

How to retrieve a video from an HTML file using wget

I am trying to download some videos from a website using wget. I used the syntax of wget.
The command is as follows:
wget https://some_link/download.mp4?lecture_id=5
The problem is that it is downloading an HTML file. However, when I right click on this link in the website and select Save target as, I get the video file which I want to save. Similarily, when I click on the link, it shows a video file that can be saved or opened.
I tried the following command but to no avail:-
wget -O vid.mp4 https://some_link/download.mp4?lecture_id=5
It created a .mp4 file but it didn't have any video in it. The size of this file was also equal to the size of the HTML file that was created before.
You can use wget with parameters to download files recursively (you can download html page with all resources needed by this page like graphics).
Alternatively you can download HTML page via wget, then look for the mp4 file using grep with regular expression and then again use wget do download only mp4 file.

Creating a static copy of a web page on UNIX command line or shell script

I need to create a static copy of a web page (all media resources, like CSS, images and JS included) in a shell script. This copy should be openable offline in any browser.
Some browsers have a similar functionality (Save As... Web Page, complete) which create a folder from a page and rewrite external resources as relative static resources in this folder.
What's a way to accomplish and automatize this on Linux command line to a given URL?
You can use wget like this:
wget --recursive --convert-links --domains=example.org http://www.example.org
this command will recursively download any page reachable by hyperlinks from the page at www.example.org not following links outside the example.org domain.
Check wget manual page for more options for controlling recursion.
You want the tool wget to mirror a site do:
$ wget -mk http://www.example.com/
Options:
-m --mirror
Turn on options suitable for mirroring. This option turns on recursion and time-stamping, sets infinite recursion depth and keeps
FTP
directory listings. It is currently equivalent to -r -N -l inf --no-remove-listing.
-k --convert-links
After the download is complete, convert the links in the document to make them suitable for local viewing. This affects not
only the
visible hyperlinks, but any part of the document that links to external content, such as embedded images, links to style sheets,
hyperlinks to non-HTML content, etc.

Resources