kla0005 Posted February 11, 2010 Share Posted February 11, 2010 Hellow guys, I have made a script that can get the html of other pages, but know i want the <body> name.. I can just take <body> because sometimes the pages have f.eks, a onload="" in it or something, so i tryed this: $body = preg_replace("/\\<body\(.+?)\>/is",'<body \1 >', $code); But that didnt work? What have i done wrong? Please help Quote Link to comment Share on other sites More sharing options...
JAY6390 Posted February 11, 2010 Share Posted February 11, 2010 The regex will be /<body\b([^>]*)>/is Quote Link to comment Share on other sites More sharing options...
cags Posted February 11, 2010 Share Posted February 11, 2010 The regex will be /<body\b([^>]*)>/is Actually the OP wants the contents of the body tag, not the actual opening body tag. The sensible solution is to use DOMDocument or some such similar parsing technology. Quote Link to comment Share on other sites More sharing options...
JAY6390 Posted February 11, 2010 Share Posted February 11, 2010 Ah oops, missed that yes in that case DOM would be far superior Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.