Re: Grabbing url from iframe
by wjw (Priest) on Feb 11, 2011 at 23:07 UTC
|
...for $65.00 an hour, I will write the code for you... otherwise, you might want to look into WWW::Mechanize
- ...the majority is always wrong, and always the last to know about it...
- The Spice must flow...
- ..by my will, and by will alone.. I set my mind in motion
| [reply] |
Re: Grabbing url from iframe
by ww (Archbishop) on Feb 12, 2011 at 01:09 UTC
|
A quick survey of your recent posts suggests that your mindset about PM is reflected in your request, "Can you give me some code (emphasis supplied) for either or both of these?"
While most are not quite such blatant 'gimmes' (which richly deserve the first part of wjw's answer) you don't seem to have internalized the notion that Monks are more than willing to help with specific issues, we prefer to see that the requestor has made some effort -- in other words, shows some code, research results or the like -- that evidence a good faith effort to solve your problem.
So please, read (and heed) On asking for help and the other basic guidance provided on the norms of the Monastery.
As to your current request: that's not a Perl issue; that's basic arithmetic:
320 = x
560 349
All you need to do is write code to handle that kind of equation.
updated: Minor rephrasing. markup fixed
| [reply] |
Re: Grabbing url from iframe
by ikegami (Patriarch) on Feb 12, 2011 at 02:29 UTC
|
Which one is it? Do you want to change the height and width, or do you want to extract* the URL of the frame's content? Those aren't remotely similar in effect.
Furthermore, you didn't given any indication of what problem you are facing. How can we help you with your problem if you don't tell us what it is?
* — You said "strip", but based on your last post, you mean "extract" when you say "strip". To strip is to remove.
| [reply] |
|
Yes, sorry I guess strip isn't the right term. I'd prefer to reduce the width and height but that seems like more of a hassle so I thought I'd simply show a graphic in place of the video on the mobile site, and provide a link to the YouTube version. Therefore, I need to be able to strip out the url.
I tried to adapt this code, but I'm not having much luck.
my $video = $video;
my @parts = split /\<iframe(.+)src=\"/http(.+)/\"(.+)\<\/iframe\>/, $v
+ideo;
(my $video )= $parts[-2] =~ m/(\d+)/;
This may not be the right way to do this at all but...
Thanks. | [reply] [d/l] |
|
The approach is fundamentally bad. You're using split, but you don't have a separated list of things to split on.
Either option you choose, you need to
- Parse the HTML
- Locate the elements
- Modify the elements
- Regenerate the HTML
In this case, that can all be done by one substitution.
s/
(<iframe
[ ]title="YouTube[ ]video[ ]player"
[ ]width=")([0-9]+)("
[ ]height=")([0-9]+)("
)
/
$1 . "320" . $3 . ( (320/$2)*$4 ) . $5
/xeg
| [reply] [d/l] [select] |
|
|
|
Re: Grabbing url from iframe
by rowdog (Curate) on Feb 12, 2011 at 07:28 UTC
|
Sounds like you need to go study up on javascript AND/OR you need to to learn about regexes AND/OR you need to pay someone some money. I'm $100 USD/hour, IFF your project isn't evil... pick your poison.
| [reply] |
Re: Grabbing url from iframe
by Anonymous Monk on Feb 12, 2011 at 01:07 UTC
|
| [reply] |
|
What I'm trying to do is either present a smaller screencap of the video for the mobile site, or not show the video at all and present a link to YouTube. Either way I have to grab the url. I've tried doing some substitutions but I can't seem to get it right. I've tried splitting up the code and putting sections into an array, but I must be doing something wrong.
| [reply] |