TransWikia.com

interact with web pages with many hyperlinks and search for a specific name or phrase How?

Mathematica Asked on August 19, 2021

I have this code that shows many hyperlinks

links = Import[
"http://www.liceobrainstorm.cl/wp-content/uploads/2020/07/", 
"Hyperlinks"]

Unfortunately some of them appear with the % symbol, I don’t know why).

the idea is that once the list is obtained I can interact with it and show me only those that meet a criterion, for example for this example all those that say "MEDIO-B", but if you can download them in a particular directory it would be great.

One Answer

Update Download for all months

(* e.g. http://www.liceobrainstorm.cl/wp-content/uploads/2020/ *)   
url = InputString["enter url"]; 

(* e.g. Matem *)
text = InputString["enter text to download"];

(* Choose directory for downloaded files *)
dir = SystemDialogInput["Directory", $HomeDirectory];

months = IntegerString[#, 10, 2] & /@ Range[12];

links = months // Map[Import[url <> # <> "/", "Hyperlinks"] &] // Flatten // Map[URLDecode];

selectedLinks = Select[links, StringContainsQ[#, text, IgnoreCase -> True] &]

If[FreeQ[dir, $Canceled], selectedLinks // URLDownload[#, dir] &, Print["Cancelled"]]

url = InputString["enter url"];

links = Import[url, "Hyperlinks"] // Map[URLDecode];

text = InputString["enter text to download"];

selectedLinks = Select[links, StringContainsQ[#, text, IgnoreCase -> True] &];

dir = SystemDialogInput["Directory", $HomeDirectory]

If[FreeQ[dir, $Canceled], selectedLinks // URLDownload[#, dir] &, Print["Cancelled"]]

Correct answer by Rohit Namjoshi on August 19, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP