How To Extract/Fetch HTML source code from another website?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
zerodevice
Forum Newbie
Posts: 2
Joined: Fri Jun 22, 2007 9:55 pm

How To Extract/Fetch HTML source code from another website?

Post by zerodevice »

Hi, I'm trying to code my php that allows me to extract or fetch the html codes from another website, then i'll filter it myself to get only the specific text i want and display or echo it directly to my page.

e.g. you goto my page, and it will display a list of google's search result based on a fixed search string i code into the page.

e.g.search "asdf"

in google it will show "http://www.google.com.my/search?hl=en&q ... arch&meta="

in my page it will show:
asdf
http://www.asdf.com/ - 3k - Cached - Similar pages

What is asdf?
http://www.asdf.com/whatisasdf.html - 5k - Cached - Similar pages

CLiki : asdf
http://www.cliki.net/asdf - 17k - Cached - Similar pages

CLiki : ASDF-Install
http://www.cliki.net/ASDF-Install - 34k - Cached - Similar pages

Association Of Synchronous Data Formats
http://www.asdf.org/ - 4k - Cached - Similar pages

Home row - Wikipedia, the free encyclopedia
en.wikipedia.org/wiki/Home_row - 16k - Cached - Similar pages

asdf Manual
constantly.at/lisp/asdf/ - 11k - Cached - Similar pages

ASDF - A Simple DVD Frontend for MPlayer
asdf-mplayer.sourceforge.net/ - 4k - Cached - Similar pages

asdf-jkl - Google Code
code.google.com/p/asdf-jkl/ - 7k - Cached - Similar pages

http://www.myspace.com/asdfrock
profile.myspace.com/index.cfm?fuseaction=user.viewprofile&friendid=31856324 - 138k - 21 Jun 2007 - Cached -
these text adn hyperlinks are extracted instantly the moment they goto my site.


i know its a dumb function, but i have my reasons.

please help me.

thanks.
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post by Benjamin »

regex curl lawyer
User avatar
The Phoenix
Forum Contributor
Posts: 294
Joined: Fri Oct 06, 2006 8:12 pm

Post by The Phoenix »

astions wrote:regex curl lawyer
That was concise, informative, and dead accurate. Awesome.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Just to follow up, in case it wasn't clear, google prohibits the usage of html scrapping from their search engine --- as noted in their terms of service.
zerodevice
Forum Newbie
Posts: 2
Joined: Fri Jun 22, 2007 9:55 pm

Post by zerodevice »

Jcart wrote:Just to follow up, in case it wasn't clear, google prohibits the usage of html scrapping from their search engine --- as noted in their terms of service.
yes, i understand that google doesn't allow such action, however i am not going to apply this on google.
i am using it for some other websites with informations i need.

google is just an example so that most people will understand wat i want.
User avatar
Gente
Forum Contributor
Posts: 252
Joined: Wed Jun 13, 2007 9:43 am
Location: Ukraine, Kharkov
Contact:

Post by Gente »

fopen() can also be useful
Post Reply