Today's Posts Follow Us On Twitter! TFL Members on Twitter  
Forum search: Advanced Search  
Navigation
Marketplace
  Members Login:
Lost password?
  Forum Statistics:
Forum Members: 24,253
Total Threads: 80,789
Total Posts: 566,436
There are 91 users currently browsing (tf).
 
  Our Partners:
 
  TalkFreelance     Design and Development     Programming     PHP and MySQL :

im loading a webpage with fopen() and fread(), then how to strip tags befor loading??

Thread title: im loading a webpage with fopen() and fread(), then how to strip tags befor loading??
Reply    
    Thread tools Search this thread Display Modes  
07-07-2010, 10:58 PM
#1
free-designer is offline free-designer
Status: Junior Member
Join date: Jun 2009
Location:
Expertise:
Software:
 
Posts: 98
iTrader: 0 / 0%
 

free-designer is on a distinguished road

  Old  im loading a webpage with fopen() and fread(), then how to strip tags befor loading??

Hey...
I think the title explains what i need, im using this function to get the title from a passed url.

the function is doing the below:
1- Im loading the first 7500 chars
2- then with regexp getting the title tag
--------------------------------------

PHP Code:
function page_title($url) {
        
        
$fp fopen($url"r");
        

        
$str fread($fp7500 );  
        
        
fclose($fp);
        
        
$res preg_match("|<[\s]*title[\s]*>([^<]+)<[\s]*/[\s]*title[\s]*>|Ui"$str$fp);
        
        if (!
$res){
            return 
"Coudn't get the title of: $url";
        }else{
            
$title $fp[1];
            return 
$title;
        }
    }

echo 
page_title("http://www.google.com"); 
i can use the file_get_contents() function instead of using fopen() and the fread() functions, because i don't have to download all the page i just need the top of the codes and not all of it cuz im getting the title, so i only get the first 7500 function.

so the problem is that for example vbulletin3 putting the title tag at the end of the <head> and the problem that <head> having very very mush tags so i coudn't get the title.

i want to strip the |<script> and <style> and <link>| tags.

any ideas...

Reply With Quote
07-08-2010, 05:43 PM
#2
Salathe is offline Salathe
Salathe's Avatar
Status: Community Archaeologist
Join date: Jul 2004
Location: Scotland
Expertise: Software Development
Software: vim, PHP
 
Posts: 3,820
iTrader: 25 / 100%
 

Salathe will become famous soon enough

Send a message via MSN to Salathe

  Old

Just do what you're doing, but grab more than 7,500 bytes. You can't magically make HTML disappear from a remote file like I think you want to.

Reply With Quote
Reply    


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

  Posting Rules  
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump:
 
  Contains New Posts Forum Contains New Posts   Contains No New Posts Forum Contains No New Posts   A Closed Forum Forum is Closed