Jump to content


Extract specific url from webpage div id


  • Please log in to reply
2 replies to this topic

#1 condemned

condemned
  • Guests

Posted 18 July 2012 - 07:42 PM

What I would like to do is get a link from a website and store it in a variable.

The webpage contains many links, but I would like to write a script that finds a specific link within the html and stores it in a variable which can be outputted later.



The website contains a whole mess of links to files with the div id of 'old'.
The line I want to copy the url from is in the div id 'latest'.

For example, if the script falls upon this line in its html:
<div id='latest'>Latest Update: <a href='ftp://example.com/ExampleFile.zip'>ExampleFile.zip</a>
I would like to the script to copy
ftp://example.com/ExampleFile.zip
to a variable, then copy
ExampleFile.zip
to a second variable and stop that part of the script to continue with the rest of the program.

#2 condemnmed

condemnmed
  • Guests

Posted 18 July 2012 - 08:06 PM

http://www.autohotke... ... adFile.htm

This looks like it would be of use, but I can't grasp how to get it to copy a single url.

#3 Sjc1000

Sjc1000
  • Members
  • 462 posts

Posted 19 July 2012 - 07:16 AM

This might be a way

URLDownloadToFile, "Url", "File"
FileRead, Var, "File"
RegExMatch(Var, ".*?>Latest Update: <a href='(.*?)'>(.*?)</a>",_)
MsgBox, %_1%`n%_2%