Jump to content

_google()


w0uter
 Share

Recommended Posts

when i tried to use the _INetGetSource() UDF on google.com/search?

it got mad at me for violating the rules. (some stuff about no bot searches).

so i made this.

it return the first 10 (unless you specified diff @ google) links about the search param's

ex usage $array = _Google('autoitscript')

$array[0] = number of links.

$array[1-10] = links.

Func _Google($s_q)
;locals
    Local $s_temp, $s_IE, $o_IE, $as_ret = ''
    $o_IE = ObjCreate ("InternetExplorer.Application")
    $o_IE.Navigate ('http://www.google.com/search?q=' & $s_q)
    While $o_IE.busy
        Sleep(10)
    WEnd
    $s_IE = $o_IE.document.body.innerHTML
    $s_IE = StringRegExp($s_IE, "<A(.*?)>", 3)
    For $i_count = 0 To UBound($s_IE) - 1
        $s_temp = StringLeft($s_IE[$i_count], StringInStr($s_IE[$i_count], '"', 0, -1) - 1)
        $s_temp = StringReplace(StringTrimLeft($s_temp, StringInStr($s_temp, '"', 0, -1)), '&amp;', '&')
        If StringLeft($s_temp, 1) = '/' Or StringInStr($s_temp, 'google') Or StringInStr($s_temp, 'cache') Then ContinueLoop
        $as_ret &= $s_temp & '&*|&%'
    Next
    $as_ret = StringTrimRight($as_ret, 5)
    $as_ret = StringSplit($as_ret, '&*|&%', 1)
    Return $as_ret
EndFunc  ;==>_Google

Edited by w0uter

My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll

Link to comment
Share on other sites

Great.

But one note to avoid the no bot message try making a new inetget function wich can also send some headers like agent;)

I made a script with mirc (how bad) wich fooled a webcam server that my request send a correct refferer;) Hmm maybe an Idea to make better inetget function wich uses tcp-sockets like I did in mirc (that was really too much work mirc is not really for making tcp scripts but ok)

And have feature the ability to choose headers (like agent referer etc or even send cookies)

Not realy difficult even if you donot have access to rfc's you can make a simple telnet like server and let a webbrowser connect to it to receive the codes you need (like the agent you want to imitate)

Thanks now I got a idea for myself ofcourse can add in a feature to get google search results (allready have few wich get weather and whats on tv for some chat using normal inetget)

The normal inetget gave me the same problems with result because it doens't accept cookies. Some websites really want to send those need to make that too. (hmm how does that work _google("rfc http"))

It seems the normal inetget function just uses a buildin function of internet explorer

Edited by MrSpacely
Link to comment
Share on other sites

Wow, you must have gigantic lung capacity to be able to speak so long without taking a breath (only one period in that whole post! :().

I would guess you're right about InetGet using Internet Explorer, seeing as the help file even specifies, "Internet Explorer 3 or greater must be installed for this function to work."

Considering your experience with TCP, perhaps you could write a UDF-style InetGet using the now built-in (beta version only, I believe) TCP functions.

Link to comment
Share on other sites

  • 3 months later...

Wow, you must have gigantic lung capacity to be able to speak so long without taking a breath (only one period in that whole post! :whistle:).

I would guess you're right about InetGet using Internet Explorer, seeing as the help file even specifies, "Internet Explorer 3 or greater must be installed for this function to work."

Considering your experience with TCP, perhaps you could write a UDF-style InetGet using the now built-in (beta version only, I believe) TCP functions.

<{POST_SNAPBACK}>

lol Indeed I speak verry long time;)

But i could create a new inetget function I was getting to It but found that autoit cannot handle NULL chars in strings or when writing files.

Wich really sucks for making inetget function except if you only want to get text data.

But I could still make it so it can handle text data can be usefull if you want to get weather info or news to your program function.

I used that info for a bot on irc wich could say the weather time and what was on tv. Only it was a half bot it typed in the chatbox. obviously its possible to make a irc client. Wich I did once in mirc make a irc client in mirc script using those sockets functions.

Mirc does have a little thing wich is better It does handle Null chars correctly because it has Bwrite and Bread and special variables. But its also much slower and not really portable as autoit script. ALso mirc cannot really work with multiple sockets because you cannot put sockets in a array there.

So i hope autoit will have binary (files and strings with NULL chars) support really soon then you can make even more things. Also a fully working inetget with header support and binary support. Maybe even more extra things like a textfilter wich can find certain parts of the text if they fixed the bug in regexp wich did not work correctly:S really anoying if you want to filter text and it sometimes doesn't understand the . operator correctly. (mental note test new beta with regexp see it fixed(note noted))

Link to comment
Share on other sites

  • 8 months later...

Hey this looks cool but I get this error:

C:\Documents and Settings\war_driver\Desktop\_google.au3 (11) : ==> Variable must be of type "Object".:

$s_IE = $o_IE.document.body.innerHTML

$s_IE = $o_IE.document.body^ ERROR

heres my code:

#include <_google.au3>

#include <array.au3>

$array = _Google("zerocool ")

_ArrayDisplay($array, "")

Am I doing something wrong??

Thanks

Check out ConsultingJoe.com
Link to comment
Share on other sites

works fine here.

---------------------------

---------------------------
[0] = 10
[1] = http://www.moviemeter.nl/user/2650
[2] = http://www.soccerquest.nl/forum/member.php?u=1797
[3] = http://www.skinbase.org/gallery.php?uname=ZeroCool
[4] = http://www.forum.doom9.nl/profile.php?mode=viewprofile&u=80
[5] = http://www.xboxworld.nl/user/8405
[6] = http://www.flashfocus.nl/forum/member.php?u=12426
[7] = http://www.zerocool.it/
[8] = http://www.ownage.nl/user/7218/
[9] = http://www.ownage.nl/user/5943/
[10]    = http://www.gameqube.nl/users.php?user=5200

---------------------------
OK   
---------------------------

My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll

Link to comment
Share on other sites

works fine here.

---------------------------

---------------------------
[0] = 10
[1] = http://www.moviemeter.nl/user/2650
[2] = http://www.soccerquest.nl/forum/member.php?u=1797
[3] = http://www.skinbase.org/gallery.php?uname=ZeroCool
[4] = http://www.forum.doom9.nl/profile.php?mode=viewprofile&u=80
[5] = http://www.xboxworld.nl/user/8405
[6] = http://www.flashfocus.nl/forum/member.php?u=12426
[7] = http://www.zerocool.it/
[8] = http://www.ownage.nl/user/7218/
[9] = http://www.ownage.nl/user/5943/
[10]    = http://www.gameqube.nl/users.php?user=5200

---------------------------
OK   
---------------------------
Thanks I got it, since I use dial up it skipped the while loop because it didnt do a loadwait, I just put a sleep(100) or so in before the while,

Thanks, and good job

Check out ConsultingJoe.com
Link to comment
Share on other sites

  • 6 months later...

It is compatible with another navigator as IE ?

W0uters func uses IEs com interface. It would be difficult and impractical (if not impossible) to use a func like this in a browser like Firefox as it has no com interface.

HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code.
Link to comment
Share on other sites

  • 2 weeks later...

W0uters func uses IEs com interface. It would be difficult and impractical (if not impossible) to use a func like this in a browser like Firefox as it has no com interface.

It may not have a com interface to the browser itself as IE does... but it does have a com control.

Link to comment
Share on other sites

  • 3 years later...

Hi my script cannot create a COM object

$o_IE = ObjCreate("InternetExplorer.Application")

Throws up

>Error code: -2146959355

Need some help

Do Not Steal The Government Hates CompetitionO2JAM AutoPlayBot [|||||.............] 10%Friendster Commenter [..................] 0%Auto Message Download Percentage [|||||||||||||||||] 100%
Link to comment
Share on other sites

#include <Array.au3>

Local $aLinks = _Google("AutoIt", 5)
If IsArray($aLinks) Then _ArrayDisplay($aLinks)


Func _Google($sQuery, $iPages = 1)
    Local $oHttpReq = ObjCreate("WinHttp.WinHttpRequest.5.1")
    Local $aLinks[11] = [0], $aResult
    Local $sResponse


    For $i = 1 To $iPages
        $oHttpReq.Open("GET", "http://www.google.com/search?q=" & $sQuery & "start="*($i-1)*10, False)
        $oHttpReq.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.4) Gecko/20100611 Firefox/3.6.4")
        $oHttpReq.Send
        $sResponse = $oHttpReq.ResponseText
        If $sResponse = "" Then ExitLoop
        $aResult = StringRegExp($sResponse, '(?i)<ol>(.+?)</ol>', 1)
        If IsArray($aResult) Then
            $aResult = StringRegExp($aResult[0], '(?i)<a href="([^"]+)"[^>]+?class=l', 3)
            If IsArray($aResult) Then
                For $j = 0 To UBound($aResult)-1
                    $aLinks[0] += 1
                    If $aLinks[0] > UBound($aLinks)-1 Then ReDim $aLinks[$aLinks[0]+50]
                    $aLinks[$aLinks[0]] = $aResult[$j]
                Next
            Else
                ExitLoop
            EndIf
        Else
            ExitLoop
        EndIf
    Next

    If $aLinks[0] = 0 Then Return 0
    ReDim $aLinks[$aLinks[0]+1]
    Return $aLinks
EndFunc

Link to comment
Share on other sites

  • 1 year later...

#include <Array.au3>
Local $aLinks = _Google("AutoIt", 5)
If IsArray($aLinks) Then _ArrayDisplay($aLinks)
 
Func _Google($sQuery, $iPages = 1)
    Local $oHttpReq = ObjCreate("WinHttp.WinHttpRequest.5.1")
    Local $aLinks[11] = [0], $aResult
    Local $sResponse
 
    For $i = 1 To $iPages
        $oHttpReq.Open("GET", "http://www.google.com/search?q=" & $sQuery & "start="*($i-1)*10, False)
        $oHttpReq.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.4) Gecko/20100611 Firefox/3.6.4")
        $oHttpReq.Send
        $sResponse = $oHttpReq.ResponseText
        If $sResponse = "" Then ExitLoop
        $aResult = StringRegExp($sResponse, '(?i)<ol>(.+?)</ol>', 1)
        If IsArray($aResult) Then
            $aResult = StringRegExp($aResult[0], '(?i)<a href="([^"]+)"[^>]+?class=l', 3)
            If IsArray($aResult) Then
                For $j = 0 To UBound($aResult)-1
                    $aLinks[0] += 1
                    If $aLinks[0] > UBound($aLinks)-1 Then ReDim $aLinks[$aLinks[0]+50]
                    $aLinks[$aLinks[0]] = $aResult[$j]
                Next
            Else
                ExitLoop
            EndIf
        Else
            ExitLoop
        EndIf
    Next
    If $aLinks[0] = 0 Then Return 0
    ReDim $aLinks[$aLinks[0]+1]
    Return $aLinks
EndFunc

I'm not getting any results form google using this code, maybe a google update?

thanks.

Edited by autoall
Link to comment
Share on other sites

I'm not getting any results form google using this code, maybe a google update?

thanks.

Probably. Considering that code is more than a year old.

(suggest you try to drop in a little more info other than a general 'Not working for me'.)

Ps: Don't select the code while adding a automated/icon

or [autoit] code tag. As it will eat the line-breaks. Just drop the (empty) code tag at the start of the code, and move the closing tag to the end of the code.

(e:That last part was for the old forum ... )

Edited by iEvKI3gv9Wrkd41u

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Link to comment
Share on other sites

Aargh autoall, please word wrap!!!

And yes, if it is old code, then it nearly certainly wont work, and Google will have dropped support for it. Try downloading the latest version. All the functions should work the same, but there will probably more. You shouldnt have any headaches with it, either... if you do it right.

Link to comment
Share on other sites

Aargh autoall, please word wrap!!!

And yes, if it is old code, then it nearly certainly wont work, and Google will have dropped support for it. Try downloading the latest version. All the functions should work the same, but there will probably more. You shouldnt have any headaches with it, either... if you do it right.

Google dropped support? Download?....strange.

I think that G never supported this...

We need to twist some tags, and it will work.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...