views:

52

answers:

1

Hi everyone,

I'm new to selenium. I want to ask about if there's a easy way to open a search result page of some urls, not just the homepages.

for examples, I search stack overflow in google. The url is here, but the return page is google homepage.Is it possible to get the result page directly? I want to scratch some result pages. If I just open the homepage then input the keywords to get the result pages, I think this way should be very slow.

Thank you for your answers.

from selenium import selenium
url ='http://www.google.com/search?hl=en&source=hp&q=stack+overflow&aq=o&aqi=&aql=&oq=&gs_rfai='
sel = selenium('localhost', 4444, '*firefox', url)
sel.start()
sel.open('/')
sel.wait_for_page_to_load(10000)
A: 

You should change your code:

from selenium import selenium
url ='http://www.google.com/'
sel = selenium('localhost', 4444, '*firefox', url)
sel.start()
sel.open('/search?hl=en&source=hp&q=stack+overflow&aq=o&aqi=&aql=&oq=&gs_rfai=')
sel.wait_for_page_to_load(10000)

So your url is pointing to the start page and you do open what you need - the search result

ZloiAdun