Register Advertise with usHelp Desk Today's Posts Search

Closed Thread
Thread Tools Search this Thread
Unread 7th Dec 2011, 06:43 AM   #1
HyperActive Warrior
War Room Member
 
Join Date: 2010
Location: Internet
Posts: 101
Thanks: 31
Thanked 19 Times in 12 Posts
Blog Entries: 1
Default
get file contents : php help needed
Share on: 
fb share twitter share gplus share more share

hello,

am trying to access html content using php ( using get_file_contents ) but it's seems too slow .. i need text only how can i access text only using this ?

rahman.warrior is offline  
Unread 7th Dec 2011, 08:55 AM   #2
VIP Warrior
War Room Member
 
Join Date: 2006
Location: , , USA.
Posts: 1,795
Thanks: 70
Thanked 287 Times in 259 Posts
Default
Re: get file contents : php help needed
Share on: 
fb share twitter share gplus share more share

What are you really trying to do?
Read an external or a local web page and then strip out the html?
Or something else?
Why don't you post an example of the code? It would be helpful.
KirkMcD is offline  
Unread 7th Dec 2011, 09:15 AM   #3
HyperActive Warrior
War Room Member
 
Join Date: 2010
Location: Internet
Posts: 101
Thanks: 31
Thanked 19 Times in 12 Posts
Blog Entries: 1
Default
Re: get file contents : php help needed
Share on: 
fb share twitter share gplus share more share

Originally Posted by KirkMcD View Post

What are you really trying to do?
Read an external or a local web page and then strip out the html?
Or something else?
Why don't you post an example of the code? It would be helpful.
get_file_contents('external URL') ;

i need only plain text , any other function ?

rahman.warrior is offline  
Unread 7th Dec 2011, 10:48 AM   #4
VIP Warrior
War Room Member
 
Join Date: 2006
Location: , , USA.
Posts: 1,795
Thanks: 70
Thanked 287 Times in 259 Posts
Default
Re: get file contents : php help needed
Share on: 
fb share twitter share gplus share more share

You can use CURL, but its still going to be slow, since you are going to an external site.
KirkMcD is offline  
The Following User Says Thank You to KirkMcD For This Useful Post:
Unread 7th Dec 2011, 11:07 AM   #5
HyperActive Warrior
War Room Member
 
Nikolas's Avatar
 
Join Date: 2007
Location: Greece
Posts: 159
Thanks: 11
Thanked 31 Times in 29 Posts
Default
Re: get file contents : php help needed
Share on: 
fb share twitter share gplus share more share

You can't make the process faster, what you can do is actually cache the results for some time (or forever) so you wont have to load the data each time someone visits the page.

You can do that by saving the data in files or in your database.
Nikolas is offline  
The Following User Says Thank You to Nikolas For This Useful Post:
Unread 7th Dec 2011, 11:55 AM   #6
Active Warrior
 
2WDHost's Avatar
 
Join Date: 2011
Posts: 96
Thanks: 0
Thanked 26 Times in 25 Posts
Default
Re: get file contents : php help needed
Share on: 
fb share twitter share gplus share more share

Originally Posted by junly View Post

get_file_contents('external URL') ;

i need only plain text , any other function ?
Check PHP Simple HTML DOM Parser. It can help you to extract the content you need from HTML page.

2WDH.com: Professional cPanel Hosting since 2003
Really helpful support. You're not a number to us! Programming, database and site development help.
No overselling. SSD. Real 99.99%+ uptime. Free 2-week trial: no obligation/credit card required.
2WDHost is offline  
Unread 7th Dec 2011, 11:58 AM   #7
HyperActive Warrior
 
Join Date: 2010
Posts: 99
Thanks: 65
Thanked 18 Times in 14 Posts
Default
Re: get file contents : php help needed
Share on: 
fb share twitter share gplus share more share

Use this to remove html:

PHP: strip_tags - Manual

so you would do something like:

$html = file_get_contents('http://www.example.com/');
$text = strip_tags($html);

Refer to the documentation for the details and some possible improvements as well.
DannyDarwin is offline  
Unread 9th Dec 2011, 01:05 PM   #8
Warrior Member
 
Join Date: 2011
Posts: 11
Thanks: 0
Thanked 2 Times in 2 Posts
Default
Re: get file contents : php help needed
Share on: 
fb share twitter share gplus share more share

To speed up the process, please use socket. The issue is network connection speed, a augmentation using strip_tags(.) will not help.


Last edited on 9th Dec 2011 at 01:11 PM. Reason: FYI: xxxx://php.tinyray.com/weather on how to PHP socket
tinyraysite is offline  
Unread 9th Dec 2011, 01:29 PM   #9
Quality > Quantity
War Room Member
 
Join Date: 2011
Location: Germany
Posts: 67
Thanks: 2
Thanked 8 Times in 8 Posts
Default
Re: get file contents : php help needed
Share on: 
fb share twitter share gplus share more share

Hello junly,
Do you make multiple http calls on a page load or just one? If you have multiple ones, I suggest you to use the Rolling Curl Class => rolling-curl - A more efficient multi-curl library for PHP (non-blocking) - Google Project Hosting this will make multiple requests at the same time so it will be finished faster.

Cheers
SeeSharp is offline  
Unread 9th Dec 2011, 02:28 PM   #10
Active Warrior
 
Join Date: 2011
Location: Philippines
Posts: 62
Thanks: 0
Thanked 0 Times in 0 Posts
Default
Re: get file contents : php help needed
Share on: 
fb share twitter share gplus share more share

Originally Posted by KirkMcD View Post

You can use CURL, but its still going to be slow, since you are going to an external site.
You should follow him.

Bhadz is offline  
Closed Thread


Bookmarks

Tags
contents, file, needed, php


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT -6. The time now is 06:45 PM.