Sign in to follow this  
Followers 0
langthang084

how to get the result link after search the website?

7 posts in this topic

I want to search something on the internet (like Google, Youtube...). And I will get the list of result links. So how to declare each link in the variable?

Share this post


Link to post
Share on other sites



Depends on the browser you use. IE, FF ...?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Short answer (ie):

#include <IE.au3> 
_IELinkGetCollection(ByRef $o_object [, $i_index = -1])

Will return much more than you want.

Long ansower, loop through the above, and grab only the valid ones...they will all follow some pattern.

Edited by jdelaney

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites

Thanks! But how to do this with Chrome?

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Here my code with IE, but why I dont use Filter with these link? and dont add $link[$i] to array?

#include <IE.au3>
 #include <Array.au3>
 #include <File.au3>


Local $oIE = _IECreate("http://www.youtube.com/results?search_query=ABCDE")
Local $oLinks = _IELinkGetCollection($oIE)
Local $iNumLinks = @extended
$link = 0
$linkend = 0
Local $sTxt = $iNumLinks & " links found" & @CRLF & @CRLF
For $oLink In $oLinks
    $sTxt &= $oLink.href & @CRLF
 Next
    $Finish = FileOpen("C:\temp.txt",  $FO_APPEND +  $FO_UTF8)
    FileWrite($Finish, $sTxt)
    _FileReadToArray("C:\temp.txt", $link)
for $i = 0 to $link[0]
   if $link[$i] = "http://www.youtube.com/watch?v=" Then
      _ArrayAdd($linkend, $link[$i])
   EndIf
Next
_ArrayDisplay($linkend, "")
Edited by langthang084

Share this post


Link to post
Share on other sites

How about:

#include <IE.au3>
#include <Array.au3>

Local $oIE = _IECreate("http://www.youtube.com/results?search_query=ABCDE")
Local $oLinks = _IELinkGetCollection($oIE)
Local $iNumLinks = @extended
$link = 0

$array = ""
Local $sTxt = $iNumLinks & " links found" & @CRLF & @CRLF
For $oLink In $oLinks
    $sTxt &= $oLink.href & @CRLF
    If StringInStr($oLink.href,"http://www.youtube.com/watch?v=") Then
        If IsArray($array) Then
            _ArrayAdd($array, $oLink.href)
        Else
            Local $array[1] = $oLink.href
        EndIf
    EndIf
Next
_ArrayDisplay($linkend, "")

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

some magic in any browser by entering this in the addressbar (google for favlets/bookmarklets) and you read out the alertbox

javascript:var list = document.getElementsByTagName("a"); alert([].slice.call(list).toString());void(0);

or more subtle thru addressbar and result in a newly created textbox (which you can read thru iuiautomation)

javascript: var list = document.getElementsByTagName("a");var textbox = document.createElement('input');textbox.type = 'text';document.body.appendChild(textbox);textbox.value=[].slice.call(list).toString();void(0);

be aware that with copy/paste you can loose text: javascript:

and with this you can automate all major browsers easily

'?do=embed' frameborder='0' data-embedContent>>

Edited by junkew

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