Jump to content

Get Link Google


Recommended Posts

:huh:

He is new. Its hard to word a question if you dont know exactly what you are asking for.

who can help me pls?

i want click page 2 on Navigate and tool add links page 2 in $KQ

 

 I am not sure that I am the right person to help you, but you can get a lot more help this way.

Please place any .au3 files you have written in a zip file.

Please upload that file here as an attachment. (Click "Full Editor" beside the post button below.)

Also, please include the current version of Autoit you have installed. If you are not sure, then please download the latest version from the main site.

Edited by Draygoes
Spoiler

 

"If a vegetarian eats vegetables,What the heck does a humanitarian eat?"

"I hear voices in my head, but I ignore them and continue on killing."

"You have forced me to raise the indifference warning to beige, it's a beige alert people. As with all beige alerts please prepare to think about the possibility of caring."

An optimist says that giving someone power DOESN'T immediately turn them into a sadist. A pessimist says that giving someone power doesn't IMMEDIATELY turn them into a sadist.

 

 
Link to comment
Share on other sites

  1. #include <ButtonConstants.au3>
  2. #include <EditConstants.au3>
  3. #include <GUIConstantsEx.au3>
  4. #include <WindowsConstants.au3>
  5. #include <IE.au3>
  6. #include <MsgBoxConstants.au3>
  7. #include <Inet.au3>
  8. #include <array.au3>
  9. #include <FF.au3>
  10. #include <String.au3>
  11.  
  12. #Region ### START Koda GUI section ### Form=
  13. $Form1 = GUICreate("GG GetLink", 615, 438, 192, 124)
  14. $Dork = GUICtrlCreateInput("autoit", 280, 8, 129, 21)
  15. $Ok = GUICtrlCreateButton("OK", 432, 8, 75, 25)
  16. $Cancel = GUICtrlCreateButton("Cancel", 520, 8, 75, 25)
  17. $Group1 = GUICtrlCreateGroup("Group1", 16, 48, 393, 369)
  18. GUICtrlCreateGroup("", -99, -99, 1, 1)
  19. $KQ = GUICtrlCreateEdit("", 432, 56, 161, 361)
  20. #EndRegion ### END Koda GUI section ###
  21.  
  22. $oIE =  _IECreateEmbedded()
  23. $Web =  GUICtrlCreateObj($oIE, 16, 48, 393, 369)
  24. $Url =  _IENavigate($oIE,"http://google.com")
  25.                 _IELoadWait($Url)
  26.  
  27.  
  28.         $nMsg = GUIGetMsg()
  29.         Switch $nMsg
  30.                 Case $GUI_EVENT_CLOSE
  31.                         Exit
  32.                 Case $Ok
  33.                         $oLink = GUICtrlRead($Link) & GUICtrlRead($Dork)
  34.                         $url=_IENavigate ($oIE, $oLink)
  35.                         _IELoadWait($url)
  36.                         GUISetState(@SW_ENABLE,$Form1)
  37.                         GetLink()
  38.                 Case $Cancel
  39.                         _IEQuit
  40.         EndSwitch
  41.  
  42. Func GetLink()
  43.         $Address = GUICtrlRead($Link) & GUICtrlRead($Dork)
  44.         $source = _INetGetSource($Address)
  45.         $source = _StringBetween($source,'<a href="/url?q=','&amp;sa=U')
  46.         $results = ""
  47.         For $i =  0 to UBound($source) - 1
  48.                 $link1 = StringReplace($source[$i],'%3D','=')
  49.                 $link = StringReplace($link1,'%3F','?')
  50.                 $results &= $link&@CRLF
  51.                 GUICtrlSetData ($KQ, $results)
  52.         Next

 

Thank for support  Draygoes , MBALZESHARI !!!! :)

with code new, i can get link page 1 good, but now i want to click link page 2 in navigate and tool auto write link page 2 in to $KQ ( but no del link page 1) .

Help me pls.

Edited by NguyenMap
Link to comment
Share on other sites

@NguyenMap

please read How to post code on the forum

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2023-04-24

Link to comment
Share on other sites

VAZcHGZ.png

Thank for all, i can get top 10 link on Page 1 of GOOGLE. Now i want to click page 2 , and tools auto write 10 link of page 2 in to $KQ. Help me...

Thank you.

so you don't what the top 10 links that the search result produces, you need the top 100??,   or do you need all links?

Link to comment
Share on other sites

 

Here, this grabs all those links on the 'google' search result pages:

#include <ie.au3>
; search results already present
$oIE = _IEAttach("Google Search")

$aLinks = BGe_IEGetDOMObjByXPathWithAttributes($oIE, "//a[@class='fl' and contains(@href,'start=')]")

For $i = 0 To UBound($aLinks)-1
    ConsoleWrite($aLinks[$i].href & @CRLF)
Next

Use the function in my signature (IEbyXPATH)...output:

https://www.google.com/search?q=something&safe=off&biw=944&bih=944&ei=ozz9U6rkMIKmigLXloHQBA&start=10&sa=N

https://www.google.com/search?q=something&safe=off&biw=944&bih=944&ei=ozz9U6rkMIKmigLXloHQBA&start=20&sa=N

https://www.google.com/search?q=something&safe=off&biw=944&bih=944&ei=ozz9U6rkMIKmigLXloHQBA&start=30&sa=N

https://www.google.com/search?q=something&safe=off&biw=944&bih=944&ei=ozz9U6rkMIKmigLXloHQBA&start=40&sa=N

https://www.google.com/search?q=something&safe=off&biw=944&bih=944&ei=ozz9U6rkMIKmigLXloHQBA&start=50&sa=N

https://www.google.com/search?q=something&safe=off&biw=944&bih=944&ei=ozz9U6rkMIKmigLXloHQBA&start=60&sa=N

https://www.google.com/search?q=something&safe=off&biw=944&bih=944&ei=ozz9U6rkMIKmigLXloHQBA&start=70&sa=N

https://www.google.com/search?q=something&safe=off&biw=944&bih=944&ei=ozz9U6rkMIKmigLXloHQBA&start=80&sa=N

https://www.google.com/search?q=something&safe=off&biw=944&bih=944&ei=ozz9U6rkMIKmigLXloHQBA&start=90&sa=N

Or, to specifically get the link to the next page:

#include <ie.au3>
; search results already present
$oIE = _IEAttach("Google Search")

$aLinks = BGe_IEGetDOMObjByXPathWithAttributes($oIE, "//a[@class='fl' and contains(@href,'start=10')]")

For $i = 0 To UBound($aLinks)-1
    ConsoleWrite($aLinks[$i].href & @CRLF)
    _IEAction($aLinks[$i],"focus")
    _IEAction($aLinks[$i],"click")
Next

So you want to do this...already have shown you how

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.
Link to comment
Share on other sites

Agreed. I even tried to give you simple instructions on how to get more help.

Please do what I recommended, and what others have instructed you to do. This is a wonderful community, but nobody can help if you refuse to follow the instructions given.

Spoiler

 

"If a vegetarian eats vegetables,What the heck does a humanitarian eat?"

"I hear voices in my head, but I ignore them and continue on killing."

"You have forced me to raise the indifference warning to beige, it's a beige alert people. As with all beige alerts please prepare to think about the possibility of caring."

An optimist says that giving someone power DOESN'T immediately turn them into a sadist. A pessimist says that giving someone power doesn't IMMEDIATELY turn them into a sadist.

 

 
Link to comment
Share on other sites

be carefull, your ip could be banned. google have a limit of queries per minute. happened to me before :)

btw, if you just want the links why dont you try:

$baselink = "https://www.google.com.vn/?gws_rd=ssl#"
$search = "SEARCH+TEXT"

for $i=0 to 100 step 10
$currentlink = $baselink&"q="&$search&"&start="&$i
$source = _InetGetSource($currentlink)
$eachlink = _StringBetween($source,'<a href="/url?q=','&amp;sa=U')
if isArray($eachlink) then
for $z=0 to ubound($eachlink)-1
msgbox(0,"",$eachlink[$z]);
next
endif
next

:alien: ~ Every Living Thing is a Code Snippet of World Application ~ :alien:

Link to comment
Share on other sites

Thanks For All :)

This is a wonderful community :D

@ Draygoes : Ok, i will zip file au3 and attach file to forum

@aNewLyfe : Code no run :(

@jdelaney : i can't run code of you with google. I use and it run with URL "autoitscript.com".

@mikell : what do you teach me ??? I can use it with my code?

GG.rar

 

This works: :)

#include "inet.au3"
#include "string.au3"

$baselink = "https://www.google.com.vn/search?output=search&sclient=psy-ab"
$search = "SEARCH+TEXT"

for $i=0 to 100 step 10
    $currentlink = $baselink&"&q="&$search&"&start="&$i
    $source = _InetGetSource($currentlink)
    $eachlink = _StringBetween($source,'<a href="/url?q=','&amp;sa=U')
    if isArray($eachlink) then
        for $z=0 to ubound($eachlink)-1
            If StringInStr($eachlink[$z], "://") Then
                msgbox(0,"",$eachlink[$z])
            EndIf
        next
    endif
next

change msgbox(0,"",$eachlink[$z]) to whatever you want to do with links...

:alien: ~ Every Living Thing is a Code Snippet of World Application ~ :alien:

Link to comment
Share on other sites

Simple question - What are you going to do with this information once you get it? I know you WANT the links. I'm asking why you need it. Maybe someone else can answer why one would need this sort of thing. I want to educate myself here.

Edited by MBALZESHARI
Link to comment
Share on other sites

Simple question - What are you going to do with this information once you get it? I know you WANT the links. I'm asking why you need it. Maybe someone else can answer why one would need this sort of thing. I want to educate myself here.

Practice? I really don't know. The program in question really doesn't have much of a use.

@The OP,

Why are you not responding? People are asking questions, because the answers will help them to help you. You have already gotten a decent solution, and  a lot of advice. So at this point you need to start answering the questions. Also, what version of Autoit are you currently using?

Spoiler

 

"If a vegetarian eats vegetables,What the heck does a humanitarian eat?"

"I hear voices in my head, but I ignore them and continue on killing."

"You have forced me to raise the indifference warning to beige, it's a beige alert people. As with all beige alerts please prepare to think about the possibility of caring."

An optimist says that giving someone power DOESN'T immediately turn them into a sadist. A pessimist says that giving someone power doesn't IMMEDIATELY turn them into a sadist.

 

 
Link to comment
Share on other sites

Thanks For All :)

This is a wonderful community :D

@ Draygoes : Ok, i will zip file au3 and attach file to forum

@aNewLyfe : Code no run :(

@jdelaney : i can't run code of you with google. I use and it run with URL "autoitscript.com".

@mikell : what do you teach me ??? I can use it with my code?

GG.rar

Runs on autoitscript.com, because that's what the samples do.  Just use the function, and vars, and remove the web crawling piece.

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.
Link to comment
Share on other sites

OFC :) I've already warned him about this.

aNewLyfe,

May  i suggest a big Sleep() inside the For loop ?

Currently the msgbox brings a delay, but if you remove this blocking part then Google will fire you as a robot  :)

 

:alien: ~ Every Living Thing is a Code Snippet of World Application ~ :alien:

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...