Jump to content

Recommended Posts

Posted

Hello Friends,

I need your advise automating Facebook search project.

I need to enter a string in a search input box, the inspect element shows me this code:

<input name="query" class="inputtext" aria-required="true" aria-label="Search" required="1" type="text" maxlength="100" placeholder="Search this group" value="" autocomplete="off">

How to treat it? as a form? as an IE object?

Really appreciating your help.

Capture.PNG

  • Developers
Posted

@avidovi,

Please do not bump your own threads within 24 hours.
Remember this is not a 24/7 support forum - those who answer are only here because they like helping others and have some time to spare.  You just have to wait until someone who knows something about your particular problem, and is willing to help, comes online.

Jos

 

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Posted (edited)
  On 12/18/2015 at 1:24 AM, avidovi said:

<input name="query" class="inputtext" aria-required="true" aria-label="Search" required="1" type="text" maxlength="100" placeholder="Search this group" value="" autocomplete="off">

How to treat it? as a form? as an IE object?

This element is normal element not a form. This can be inside form or inside frame.

Each HTML element should be treated as part of IE object.

EDIT:

  On 12/18/2015 at 1:24 AM, avidovi said:

I need to enter a string in a search input box, the inspect element shows me this code:

<input name="query" class="inputtext" aria-required="true" aria-label="Search" required="1" type="text" maxlength="100" placeholder="Search this group" value="" autocomplete="off"

Did you try anything ? Show here your code snippet.

Edited by mLipok

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:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted (edited)

mLipok thanks for answering

i used this peace of code:

$colForms = _IEFormGetCollection ($oIE)
For $oForm In $colForms ; loop over form collection

    ConsoleWrite("---- FORM " & $oForm.name & " --------------------" & @CRLF)
    $oFormElements = _IEFormElementGetCollection($oForm) ; get all elements

    For $oFormElement In $oFormElements ; loop over element collection


        If StringLower($oFormElement.tagName) == 'input' Then ; it is an input
            ConsoleWrite("> input." & $oFormElement.type & " " & $oFormElement.name & @CRLF)
            _IEFormElementSetValue($oFormElement, "2", 0) ; set value of the field

        ElseIf StringLower($oFormElement.tagName) == 'textarea' Then ; it is a textarea
            ConsoleWrite("> textarea." & $oFormElement.type & @CRLF)
            _IEFormElementSetValue($oFormElement, "1", 0) ; set value of the field

        ElseIf StringLower($oFormElement.tagName) == 'select' Then ; it is a select
            ConsoleWrite("> select." & $oFormElement.type & @CRLF)
            _IEFormElementOptionSelect($oFormElement,"4")

        EndIf

    Next
next

the console shows that its a form (input.text, name "query")  the thing is that i cannot isolate it

Edited by avidovi
Posted (edited)

Show me some a little more with HTML
Show me some more of HTML code.

Edited by mLipok

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:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted (edited)

This is my code:

#include <MsgBoxConstants.au3>
#include <IE.au3>

Local $oIE = _IECreate("https://www.facebook.com")
Local $oForm1 = _IEGetObjById($oIE, "email")
Local $oForm2 = _IEGetObjById($oIE, "pass")
Local $oButton_Login = _IEGetObjById($oIE, "loginbutton")

;Entering UserName
_IEFormElementSetValue($oForm1, "xxx@xxx.com")

;Entering password
_IEFormElementSetValue($oForm2, "xxx")

;Click the login button by ID
_IEAction($oButton_Login, "Click")

;Waits for the page to load
_IELoadWait($oIE)

;Going to the first Group
_IENavigate($oIE,"https://www.facebook.com/groups/ganyavne1/")

this is the first step, i tried to use many examples but i am not getting the hand of it, to put a string in the search post (picture attached in the first post).

I am thinking using  _IEFormElement but running $colForms = _IEFormGetCollection ($oIE) returns nothing!

 

Thanks!!!!

 

Edited by avidovi
Posted (edited)

I see your are able to correctly login to the Facebook. I do not have account and do not want to have.

So please again show me some more of HTML code, as this:

<input name="query" class="inputtext" aria-required="true" aria-label="Search" required="1" type="text" maxlength="100" placeholder="Search this group" value="" autocomplete="off">

too little.

 

Edited by mLipok

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:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

Hi mLipok,

 

I have succeeded to set the value by a small if condition.

Next stage i need to press the search icon, i have tried to press the "enter" key but it was unsuccessful.

html code of the button:

<button title="Search this group" aria-label="Search" type="submit"><span class="accessible_elem">Search this group</span></button>

here is the code:

#include <MsgBoxConstants.au3>
#include <IE.au3>

Local $oIE = _IECreate("https://www.facebook.com")
Local $oForm1 = _IEGetObjById($oIE, "email")
Local $oForm2 = _IEGetObjById($oIE, "pass")
Local $oButton_Login = _IEGetObjById($oIE, "loginbutton")

;Entering UserName
_IEFormElementSetValue($oForm1, "xx@gmail.com")

;Entering password
_IEFormElementSetValue($oForm2, "xxx")

;Click the login button by ID
_IEAction($oButton_Login, "Click")

;Waits for the page to load
_IELoadWait($oIE)

;Going to the first Group
_IENavigate($oIE,"https://www.facebook.com/groups/ganyavne1/")

$colForms = _IEFormGetCollection ($oIE)
For $oForm In $colForms ; loop over form collection

;~     ConsoleWrite("---- FORM " & $oForm.name & " --------------------" & @CRLF)
    $oFormElements = _IEFormElementGetCollection($oForm) ; get all elements


    For $oFormElement In $oFormElements ; loop over element collection

        If StringLower($oFormElement.tagName) == 'input' and StringLower($oFormElement.name) == 'query' Then ; it is an input
            ConsoleWrite("--> input." & $oFormElement.type & " " & $oFormElement.name & @CRLF)
            _IEFormElementSetValue($oFormElement,"txt",0) ; set value of the field

        EndIf

    Next
next

Thanks again for helping!!!

Posted

You're welcome!

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:

  Reveal hidden contents

Signature last update: 2023-04-24

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
×
×
  • Create New...