| | #1 |
| HyperActive Warrior War Room Member Join Date: 2010 Location: Internet
Posts: 101
Thanks: 31
Thanked 19 Times in 12 Posts
Blog Entries: 1 |
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 ? |
| | |
| |
| | #2 |
| VIP Warrior War Room Member Join Date: 2006 Location: , , USA.
Posts: 1,795
Thanks: 70
Thanked 287 Times in 259 Posts
|
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. |
| |
| | #4 |
| VIP Warrior War Room Member Join Date: 2006 Location: , , USA.
Posts: 1,795
Thanks: 70
Thanked 287 Times in 259 Posts
|
You can use CURL, but its still going to be slow, since you are going to an external site.
|
| |
| The Following User Says Thank You to KirkMcD For This Useful Post: |
| | #5 |
| HyperActive Warrior War Room Member Join Date: 2007 Location: Greece
Posts: 159
Thanks: 11
Thanked 31 Times in 29 Posts
|
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. |
| |
| The Following User Says Thank You to Nikolas For This Useful Post: |
| | #6 |
| Active Warrior Join Date: 2011
Posts: 96
Thanks: 0
Thanked 26 Times in 25 Posts
| |
| 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. | |
| |
| | #7 |
| HyperActive Warrior Join Date: 2010
Posts: 99
Thanks: 65
Thanked 18 Times in 14 Posts
|
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. |
| |
| | #8 |
| Warrior Member Join Date: 2011
Posts: 11
Thanks: 0
Thanked 2 Times in 2 Posts
|
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 | |
| |
| | #9 |
| Quality > Quantity War Room Member Join Date: 2011 Location: Germany
Posts: 67
Thanks: 2
Thanked 8 Times in 8 Posts
|
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 |
| |
| | #10 |
| Active Warrior Join Date: 2011 Location: Philippines
Posts: 62
Thanks: 0
Thanked 0 Times in 0 Posts
| |
| | |
| |
|
| Bookmarks |
| Tags |
| contents, file, needed, php |
| |