Jump to content

feed search term into a url

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
13 replies to this topic

#1
pragan

pragan

    Newbie

  • Members
  • Pip
  • 3 posts
hi,

I am trying to write a script which can do the following. I do not have any idea of how to write it ..but have the idea of how it should/will work.

I have a list of words in an mysql db(almost 1000 words). I need to take each word and then put in the search query of any search engine(for example ask.com) and store the result that appears under "related words"/"suggested words"/"narrow your search words" in a file.

Example:
If you search for the word "forum" in ask.com, we can see the url as
forum - Ask.com Web Search

and the search result page contains "Narrow Your Search"

Roman Forum
Free Forum
..
...
etc.

So I need to write a script that can take word by word from my mysql db and put it in the url (as below) and then store only the "result under "Narrow your search result" in a file.
Ask.com Search Engine - Better Web Searchnextword&search=search&qsrc=0&o=0&l=dir

Please let me know if its something possible and if I can have look at any examples..I would need to complete this as soon as possible.

I can explain it in a more better way if the above explanation is not clear.

Regards

#2
Guest_Jordan_*

Guest_Jordan_*
  • Guests
This sounds possible. First "select" all of the words from your database and do a loop. I recommend using MySQLi if you have it installed. I wrote a blog on it here: PHP MySQL Improved

Next you'll use Curl to emulate a browser and connect to the search engine submitting the keyword you extracted from the database. From there you can retrieve the data and modify it how you like.

#3
Xav

Xav

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 13,118 posts
... and to extract it, use getch().

Edited by Xav, 24 June 2008 - 11:01 AM.

Jordan said:

Good members, like yourself, stick around and post for ages to come!
Mr. Xav | Blog | Forums

#4
Guest_Jordan_*

Guest_Jordan_*
  • Guests
Curl will return the contents of the website, he will just need to assign it to a string.

#5
Xav

Xav

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 13,118 posts
I didn't say "retrieve", I said "extract". ;)
Jordan said:

Good members, like yourself, stick around and post for ages to come!
Mr. Xav | Blog | Forums

#6
Guest_Jordan_*

Guest_Jordan_*
  • Guests
lol. Also, there is no getch() function in PHP. There is ncurses_getch although it is experimental.

#7
Xav

Xav

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 13,118 posts
I thought that was the one used for extracting specific data from HTML?
Jordan said:

Good members, like yourself, stick around and post for ages to come!
Mr. Xav | Blog | Forums

#8
Guest_Jordan_*

Guest_Jordan_*
  • Guests
Nope, unless it was custom made.

#9
Xav

Xav

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 13,118 posts
Oh - is it preg_match?
Jordan said:

Good members, like yourself, stick around and post for ages to come!
Mr. Xav | Blog | Forums

#10
Guest_Jordan_*

Guest_Jordan_*
  • Guests
You can use that with regular expressions to extract most of the HTML data you would need.

#11
Xav

Xav

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 13,118 posts
Hurrah. getch() must have been one of John's custom functions or something, that I latched onto. ;)
Jordan said:

Good members, like yourself, stick around and post for ages to come!
Mr. Xav | Blog | Forums

#12
John

John

    Writes binary right handed and hex left handed

  • Moderators
  • 6,321 posts
Don't use me a scapegoat for your mistake. I cannot recall ever creating a custom PHP function with that name. However, getch() is a nonstandard C++ function to get a character from the keyboard. php