Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
getElementsByTagName from current url
Old 09-02-2011, 08:39 AM getElementsByTagName from current url
praveen's Avatar
Life is a Dream

Posts: 3,591
Name: Praveen
Location: Chennai, India
Trades: 0
I am trying to parse through the current page so that i can get the attribute of the embed tag.

The below works fine if i give a url, but instead of giving an url, i would like to parse the current page and then get the value of embed.

Also, this code is being used in a smarty template and there is a variable defined for the current url.

I tried with the variable name, but i got this error

"Call to a member function get_template_vars() on a non-object"

Can anyone help?

FYI - i am not an expert in php, so plz go easy on me.


PHP Code:
$url="http://www.xxxxx.com";

$html file_get_contents($url);

$doc = new DOMDocument();
@
$doc->loadHTML($html);

$tags $doc->getElementsByTagName('embed');

foreach (
$tags as $tag) {
       echo 
$tag->getAttribute('src');

__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
praveen is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 09-02-2011, 08:49 AM Re: getElementsByTagName from current url
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,384
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
use the 'REQUEST_URI' server variable.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 09-02-2011, 09:31 AM Re: getElementsByTagName from current url
praveen's Avatar
Life is a Dream

Posts: 3,591
Name: Praveen
Location: Chennai, India
Trades: 0
this is what i used in the template

PHP Code:
{php}
$url=$_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"];
$html file_get_contents($url);
$doc = new DOMDocument();
@
$doc->loadHTML($html);
$tags $doc->getElementsByTagName('embed');

foreach (
$tags as $tag) {
       echo 
$tag->getAttribute('src');
}

{/
php
and i got this error

Quote:
Warning: file_get_contents(http://www.abc.com/videos/ventuno/zx...4db2345f0.html) [function.file-get-contents]: failed to open stream: No such file or directory in [path]/videos/Smarty/templates_c/%%AB^AB9^AB983520%%detailheader.tpl.php on line 17
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
praveen is offline
Reply With Quote
View Public Profile
 
Old 09-02-2011, 11:35 AM Re: getElementsByTagName from current url
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,384
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Find where the HTML entities are from and remove them.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 09-02-2011, 02:09 PM Re: getElementsByTagName from current url
praveen's Avatar
Life is a Dream

Posts: 3,591
Name: Praveen
Location: Chennai, India
Trades: 0
Quote:
Originally Posted by chrishirst View Post
Find where the HTML entities are from and remove them.
i dont understand and i dont know. my knowledge of php is very limited.
More help chris. Thanks.
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
praveen is offline
Reply With Quote
View Public Profile
 
Old 09-02-2011, 03:04 PM Re: getElementsByTagName from current url
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,384
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
are "zxczczxcz-video_4db2345f0" and "/templates_c/%%AB^AB9^AB983520%%detailheader" part of the actual URIs or is it something from a rewrite?
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 09-02-2011, 11:43 PM Re: getElementsByTagName from current url
praveen's Avatar
Life is a Dream

Posts: 3,591
Name: Praveen
Location: Chennai, India
Trades: 0
Quote:
are "zxczczxcz-video_4db2345f0"
part of the final url structure
http://www.sitename.com/videos/usern..._uniqueid.html

Quote:
/templates_c/%%AB^AB9^AB983520%%detailheader
this is the smarty template cache thing
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
praveen is offline
Reply With Quote
View Public Profile
 
Old 09-03-2011, 09:48 AM Re: getElementsByTagName from current url
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,918
Name: Keith Marshall
Location: Connecticut
Trades: 0
You can use output buffering http://php.net/manual/en/book.outcontrol.php

You then create a custom function and use it as the callback parameter to evaluate the output string of the page.
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Old 09-03-2011, 12:00 PM Re: getElementsByTagName from current url
praveen's Avatar
Life is a Dream

Posts: 3,591
Name: Praveen
Location: Chennai, India
Trades: 0
hmm... i guess i might need some professional help on this. Its beyond my grasp
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
praveen is offline
Reply With Quote
View Public Profile
 
Old 09-05-2011, 10:29 AM Re: getElementsByTagName from current url
praveen's Avatar
Life is a Dream

Posts: 3,591
Name: Praveen
Location: Chennai, India
Trades: 0
Got this fixed Thanks guys
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
praveen is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to getElementsByTagName from current url
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 3.38393 seconds with 12 queries