Sign in to follow this  
Followers 0
Rickname

How to get the Title of a Link ?

8 posts in this topic

#1 ·  Posted (edited)

How can I take the title of a link, just like the browsers does ? For example , as you know, all the tabs from the browser, have a name, based on what link is opened in them. So how can I take that name of a link with AutoIT and without the help of the browser ?

Edited by Rickname

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

Yes, the examples are the best methods to explain it better :

I uploaded the picture :post-78453-0-62370700-1391375658_thumb.j

That titles I want to extract, NOT EXACTLY THIS ONES , but any title from any link !

Edited by Rickname

Share this post


Link to post
Share on other sites

Look up WinGetTitle in the help file.

Share this post


Link to post
Share on other sites

Given a URL, you could use the WinHTTP UDF to read the web page and then extract the title from the returned data.

1 person likes this

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

have a look to all the _IE* function in the help

maybe the _IELinkGetCollection function can be of help for your case

when you have a reference to the link, use the .href property to "extract" the url of that link

(see the example in the help)

EDIT:

sorry, misunderstood your question
what you need should be the ".document.title" property
if you use IE try this as example:

#include <IE.au3>
$oIE = _IECreate("www.autoitscript.com")
MsgBox(0,"",$oIE.document.title)
Edited by PincoPanco

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Share this post


Link to post
Share on other sites

Great Information Danp2 ! I did what you said, and it worked :

So you just need to get the source of the webpage via this function : _IEDocReadHTML() , then extract the text that is enclosed between the <title> </title> tags !

Thats the name of the link !

Thankyou so much !

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Similar Content

    • nacerbaaziz
      By nacerbaaziz
      Hi guys
      In this publication I will share with you a function i have written it
      This function enables you to get names of days in three languages
      English, French and Arabic
      It automatically recognizes the language of your system
      If you want, you can customize the display language you want
      English = 0
      Arabic = 1
      French = 2
      get_day_name.au3
    • boltonebob
      By boltonebob
      Could someone please explain to me how you can use Func_SearchLastState more than once in the same script.
      My situation is I am trying to use it in the same script under different case scenarios:
      e.g.
      Case 1
      Func_SearchLastState($sMachine)
      Case 2
      Func_SearchLastState($sLaptop)
       
      Even though these are under different case scenarios the Func_SearchLastState is getting picked up as a duplicate function name.
      How can I use this function more than one in my script without getting the error?
    • robertcollier4
      By robertcollier4
      Choose a directory of link files to replace substring paths.
      LNKSubstringReplacer.au3
      _RecFileListToArray.au3

       
      #include <Array.au3> #include <_RecFileListToArray.au3> #include <File.au3> $modalSimulMode = MsgBox (3, "Simulated mode?" ,"Would you like to perform this substring replacement of link files in simulated mode? In simulated mode you will see what would have happened in a file named" & @CRLF & "LNKSubstringReplacer Results.txt" & @CRLF & @CRLF & "but no changes will be made" & @CRLF & @CRLF & "Yes - simulated mode, no changes will be made" & @CRLF & "No - resaving mode, changes will be made") If $modalSimulMode = 2 Then Exit ElseIf $modalSimulMode = 6 Then $saveAgain = False ElseIf $modalSimulMode = 7 Then $saveAgain = True ElseIf MsgBox(0, "ERROR", "Error with asking simulated mode, exiting") EndIf Local $dirToSearchDefault = @ProgramsCommonDir ; Local $dirToSearchDefault = "T:\testdir" Local $dirToSearch = InputBox("Select directory", "In which directory would you like to search for files to perform substring link replacement for?", $dirToSearchDefault, "", 520, 320) If $dirToSearch = "" Then Exit EndIf Local $StrToSearch = InputBox("Specify substring to search for", "What substring would you like to be replaced for link target and link working directory?", "", "", 520, 320) ; If $StrToSearch = "" Then ; allow empty input in case just want to resave and fix all links If @error = 1 Then Exit EndIf Local $StrToReplace = InputBox("Specify substring to replace with", "All occurrences of" & @CRLF & $StrToSearch & @CRLF & @CRLF & "Contained in links in the directory " & @CRLF & $dirToSearch & @CRLF & @CRLF & "Should be replaced with what?", $StrToSearch, "", 520, 320) ; If $StrToSearch = "" Then ; allow empty input in case just want to resave and fix all links If @error = 1 Then Exit EndIf Local $listFiles = _RecFileListToArray($dirToSearchDefault, "*", 1, 1, 0, 2) If (Not IsArray($listFiles)) and (@Error=1) Then MsgBox (0,"","No files found in search path, exiting") Exit EndIf ; _ArrayDisplay($listFiles, "$aFileList") ; Write simulated results to a text file $dateNow = @YEAR & "-" & @MON & "-" & @MDAY & "_" & @HOUR & @MIN & @SEC $fileLnkPath = @ScriptDir & "\" & $dateNow & " LNKSubstringReplacer Results.txt" FileDelete($fileLnkPath) Local $fileTextList = FileOpen($fileLnkPath, $FO_APPEND) If $fileTextList = -1 Then MsgBox(0, $fileLnkPath, "FileOpen Error, exiting") Exit EndIf FileWrite($fileTextList, "---------------------------------------" & @CRLF) FileWrite($fileTextList, "Link file to scan" & @CRLF) FileWrite($fileTextList, "Link target" & @CRLF) FileWrite($fileTextList, "Link working directory" & @CRLF) Local $thisExtension = "" Local $sDrive = "", $sDir = "", $sFileName = "" For $i = 1 To $listFiles[0] ; Only do LNK extension Local $listFilesPathSplit = _PathSplit($listFiles[$i], $sDrive, $sDir, $sFileName, $thisExtension) ; MsgBox(0, $i, $listFiles[$i] & " , " & $thisExtension) If(StringCompare(".lnk", $thisExtension, 2) == 0) Then ; If(NOT StringCompare(".lnk", $thisExtension, 2)) Then FileWrite($fileTextList, @CRLF & "---------------------------------------" & @CRLF) FileWrite($fileTextList, $listFiles[$i] & @CRLF) Local $thislnkArray = FileGetShortcut($listFiles[$i]) If(NOT @error) Then If($thislnkArray[0] <> "") Then ; _ArrayDisplay($lnkArray) ; FileWrite($fileTextList, $thislnkArray[0] & @CRLF) ; FileWrite($fileTextList, $thislnkArray[2] & @CRLF) FileWrite($fileTextList, $thislnkArray[0] & $thislnkArray[2] & @CRLF) FileWrite($fileTextList, $thislnkArray[1] & @CRLF) ; Allow empty $StrToSearch or empty $strToReplace just to fix and resave all links If( ($StrToSearch = "") OR ($StrToReplace = "") ) Then $newLinkTarget = RemoveSurrQuotes($thislnkArray[0]) $newLinkTargetArgs = $thislnkArray[2] $newLinkWorkingDir = RemoveSurrQuotes($thislnkArray[1]) Else $newLinkTarget = RemoveSurrQuotes(StringReplace($thislnkArray[0], $StrToSearch, $StrToReplace)) $newLinkTargetArgs = StringReplace($thislnkArray[2], $StrToSearch, $StrToReplace) $newLinkWorkingDir = RemoveSurrQuotes(StringReplace($thislnkArray[1], $StrToSearch, $StrToReplace)) EndIf ; Remove ending backslash from working dir While (StringRight($newLinkWorkingDir, 1) = "\") $newLinkWorkingDir = StringTrimRight($newLinkWorkingDir, 1) WEnd If($saveAgain) Then FileWrite($fileTextList, @CRLF & "Resaved:" & @CRLF) FileWrite($fileTextList, $listFiles[$i] & @CRLF) FileWrite($fileTextList, $newLinkTarget & " " & $newLinkTargetArgs & @CRLF) FileWrite($fileTextList, $newLinkWorkingDir & @CRLF) $saveResult = FileCreateShortcut( _ $newLinkTarget, _ $listFiles[$i], _ $newLinkWorkingDir, _ $newLinkTargetArgs, _ $thislnkArray[3], _ $thislnkArray[4], _ "", _ $thislnkArray[5], _ $thislnkArray[6] _ ) If(NOT $saveResult) Then FileWrite($fileTextList, "ERROR Unable to resave: " & $listFiles[$i] & @CRLF) EndIf Else FileWrite($fileTextList, @CRLF & "Simulated Resave:" & @CRLF) FileWrite($fileTextList, $listFiles[$i] & @CRLF) FileWrite($fileTextList, $newLinkTarget & " " & $newLinkTargetArgs & @CRLF) FileWrite($fileTextList, $newLinkWorkingDir & @CRLF) EndIf Else FileWrite($fileTextList, "Found empty link target, skipping " & @CRLF) EndIf Else FileWrite($fileTextList, "FileGetShortcut Error, skipping " & @CRLF) Exit EndIf Else FileWrite($fileTextList, @CRLF & "---------------------------------------" & @CRLF) FileWrite($fileTextList, $listFiles[$i] & @CRLF) FileWrite($fileTextList, "Skipping not a link file" & @CRLF) EndIf Next FileClose($fileTextList) ;--------------------------------------------------------------- Func RemoveSurrQuotes($myString) Return StringReplace($myString, '"', '') EndFunc ;---------------------------------------  
    • 31290
      By 31290
      Hi everyone, 
      Following this page:
      http://downloads.dell.com/published/pages/latitude-e5450-laptop.html
      I have to download the BIOS for the E5440 model. As I don't know in which order Dell will place the description and the link to download the file (also because the 5440 can be put in first) I'd like to make  the following piece of code to search only first the link that deals with the E5440:
      (The only thing I'm sure is that the string E5440 will be either in the first or the second position and I need to download the corresponding link)
      Local $sRead = InetRead('http://downloads.dell.com/published/pages/latitude-e5450-laptop.html', 1) ConsoleWrite(BinaryToString($sRead) & @CRLF) Local $aData = _StringBetween(BinaryToString($sRead), 'Type: BIOS', 'Category:') TrayTip("", "Downloading latest BIOS Version, please wait...", 10, 3) Local $aLinks = _StringBetween($aData[0], '<A HREF="/', '"><IMG') For $i = 0 To UBound($aLinks) - 1 $aLinks[$i] = 'http://downloads.dell.com/' & $aLinks[$i] Next Local $hDownload = InetGet($aLinks[0], @DesktopDir & "\BIOSE5450.exe", $INET_FORCERELOAD, $INET_DOWNLOADBACKGROUND) Do Sleep(250) Until InetGetInfo($hDownload, $INET_DOWNLOADCOMPLETE) Local $iBytesSize = InetGetInfo($hDownload, $INET_DOWNLOADREAD) Local $iFileSize = Round(FileGetSize(@DesktopDir & "\BIOSE5450.exe") / 1048576) InetClose($hDownload) MsgBox(0, "", "The latest E5450 BIOS (" & $iFileSize & " MB) have been downloaded")
      I was thinking of an string search in the array but all my attempts failed for now.
      Can someone could give me a hand over here.
       
    • electrons
      By electrons
      hi everyOne
       
      how can control Flash elements (Button , Text , ..) or make autologin to website ?
       
      thanks and Sorry For My Basic English