Sign in to follow this  
Followers 0
dufran3

Trying to use search feature on website through script

45 posts in this topic

#1 ·  Posted (edited)

I am trying to get the search input information, so that I can input text and submit the search via a script...I believe this is the prudent code, and this is what I am trying to do. Nothing happens, no errors, and it doesn't type anything into the search input. I have tried using IE Builder, but I cannot figure out how to input text into that search field...I have done this on other websites...but this isn't working right...maybe you can look at the source snippet and see. The first snippet is what IE Builder gave me under the "form elements". 2nd code is some actual HTML source snippets. 3rd is my script trying to interact with it.

IE-Builder v2.0.0
Object Type  Object Count  
DispHTMLFormElement 4 

Elements for form 0
Index Tag Name Id Extra Information Object Type 
0 INPUT q   Form Input Type: text
Value: Search DispHTMLInputElement 
1 SELECT Category    DispHTMLSelectElement 
2 SELECT searchFP    DispHTMLSelectElement 
3 INPUT  Form Input Type: submit
Value: Search DispHTMLInputElement

HTML Source snippet

<form class="searchForm" method="get" action="/search/query/p/">
<div>
[<a href="http://&#()#.com/SearchHelp" onclick="openwin(href); return false;">help me with search</a>]
<label accesskey="S">Search</label>

<select name="searchFP" tabindex="3">
<option value="p" selected="selected">Posts</option>
<option value="f" >Files</option>
<!--<option value="n" >NFOs</option>
-->
</select>
<input type="submit" value="Search" tabindex="4" />
</div>
</form>
</div> <!-- }}} -->

<div id="Main">

not going to post the whole script, just the part that isn't working, the entering text into search input and clicking search

;Search
    $oSearchInput = _IEGetObjByName($oIE, 'SearchFP')
    _IEFormElementSetValue($oSearchInput , 'SEARCH I SAY')

Edit: Removed other form elements returned by IE-Builder, only need form 0

Edited by dufran3

Share this post


Link to post
Share on other sites



Another little snippet....

<label accesskey="S">Search</label>
<input type="text" value="Search&hellip;" onfocus="if (value=='Search&hellip;') value='';" onblur="if(value=='') value='Search&hellip;';" size="25" name="q" tabindex="1" />

See, the name says "q" so I tried to use that but didn't work....

Share this post


Link to post
Share on other sites

Is there a way to get it by class??? because apparently the class=searchForm...but can't interact with it...

Share this post


Link to post
Share on other sites

I know Dale or Valuater can pwn me on this one...:-(

Share this post


Link to post
Share on other sites

Were you able to obtain the Form object? Once that's done, you should be able to access "SearchFP" using _IEFormElementGetObjByName.

Share this post


Link to post
Share on other sites

Were you able to obtain the Form object?

I'm not sure how to obtain the form object? _IEFormGetCollection?? tried that, but not sure if it is returning anything, or how to use that function...

Share this post


Link to post
Share on other sites

When using this:

$oForm = _IEFormGetCollection ($oIE, 0) ;This would grab the first form
    $oSearchInput = _IEFormElementGetObjByName($oForm, 'SearchFP')
    _IEFormElementSetValue($oSearchInput , 'SEARCH I SAY')oÝ÷ Ú­¶)ඬzºè­«­¢+Ø´´ØÈì%¹ÔÌ]ɹ¥¹É½´Õ¹Ñ¥½¸}%½ÉµÑ
½±±Ñ¥½¸°ÀÌØí}%MÑÑÕÍ}9½5Ñ (´´ØÈì%¹ÔÌÉɽÈɽ´Õ¹Ñ¥½¸}%½Éµ±µ¹ÑÑ=©    å9µ°ÀÌØí}%MÑÑÕÍ}%¹Ù±¥ÑQåÁ(´´ØÈì%¹ÔÌÉɽÈɽ´Õ¹Ñ¥½¸}%½Éµ±µ¹ÑMÑY±Õ°ÀÌØí}%MÑÑÕÍ}%¹Ù±¥ÑQåÁ(Ðíá¥Ð½èÀQ¥µèÄĸÄØØ

Share this post


Link to post
Share on other sites

How about

$oForms = _IEFormGetCollection ($oIE)
MsgBox(0, "Forms Info", "There are " & @extended & " forms on this page")

If this source code is present:

CODE
<form class="searchForm" method="get" action="/search/query/p/">

<div>

[<a href="http://&#()#.com/SearchHelp" onclick="openwin(href); return false;">help me with search</a>]

<label accesskey="S">Search</label>

<select name="searchFP" tabindex="3">

<option value="p" selected="selected">Posts</option>

<option value="f" >Files</option>

<!--<option value="n" >NFOs</option>

-->

</select>

<input type="submit" value="Search" tabindex="4" />

</div>

</form>

Then, _IEFormGetCollection should find something.

Share this post


Link to post
Share on other sites

Msgbox says there are 0 forms on the page...

Share this post


Link to post
Share on other sites

it could be a problem with IE7 as _IECreate opens up 2 IE windows....

Share this post


Link to post
Share on other sites

When using this code

#include<IE.au3>

$oIE = _IECreate()
_IENavigate($oIE,'www.google.com')oÝ÷ Ùh^îØb³­;Ú)z{.¥¦åjy0whÂØ^^Ë©jw°Â)Ý£    Ú¾(µçm¢ØZµ§]­ë,I©Â+a¶¬r^jëh×6#include<IE.au3>

$oIE = _IECreate('www.google.com')

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

If you already have an IE window open while running the _IECreate function, have you tried attaching?

_IECreate("www.google.com", 1)

Maybe you need to brush up on the IE.au3 help files?

Edit: There aren't any frames, are there?

Edited by GMK

Share this post


Link to post
Share on other sites

Whats the URL for the page?


# MY LOVE FOR YOU... IS LIKE A TRUCK- #

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

www.newzbin.com

i'm just trying to use the search feature...

Edited by dufran3

Share this post


Link to post
Share on other sites

Could try,

$oHTTP = ObjCreate("winhttp.winhttprequest.5.1")
$oQuery = "LULZ I R GUD SERCHER"
$oHTTP.Open("GET", "http://www.newzbin.com/search/query/p/?q=" & $oQuery & "&Category=-1&searchFP=p")
$oHTTP.Send()
ConsoleWrite($oHTTP.ResponseText & @CRLF)

But then again, Httprequests are my answers to everything.


# MY LOVE FOR YOU... IS LIKE A TRUCK- #

Share this post


Link to post
Share on other sites

I don't think an http request is going to work for this. thanks though!

Share this post


Link to post
Share on other sites

Well, It works for me.


# MY LOVE FOR YOU... IS LIKE A TRUCK- #

Share this post


Link to post
Share on other sites

searchFP is a select box so you can only set its "selected" value.

p is the input text box which you need to set your search value.

Without knowing how your program flows you could cut out the middleman altogether and build your search query into the url string rather than manipulate the form and navigate directly to the results page:

$q="test"

$Category =-1

$searchFP="p"

$searchstring ="http://www.newzbin.com/search/query/p/?q=" & $q & "&Category=" & $Category & "&searchFP=" & $searchFP

builds

http://www.newzbin.com/search/query/p/?q=t...&searchFP=p

Share this post


Link to post
Share on other sites

That too. xD


# MY LOVE FOR YOU... IS LIKE A TRUCK- #

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