-1

I need to grab the width2 and height2.

// JScript File
// JScript File
iframeW = parseInt(width) + 10;
iframeH = parseInt(height) + 10;

width2 = parseInt(width) + -9 ;
height2 = parseInt(height) + 2;

document.write('<ifr'+'ame width='+iframeW+' height='+iframeH+' scrolling=no frameborder=0 scrolling=no allowtransparency=true src=http://zzzz.zzzz-zzzzzz.com/embed.php?id='+file+'&width='+width2+'&height='+height2+'&key2=1114></ifr'+'ame>');

Originally width=600 and height=400 when it runs in the browser. It comes out as width=591 and height=402. The problem is it almost changes daily.

http://zzzz.zzzz-zzzz.com/embed.php?id=channel1&width=591&height=402&key2=1114

and so it messes up my regex, since it keeps changing the width and height. Anyway how I can grab this automatically with either regex or python.

Sorry, newb at this...slow learning process :(

Thank you.

winhowes
  • 7,845
  • 5
  • 28
  • 39
S X
  • 19
  • 1
  • 7
  • You can't do this with Python. Regex and Python are not valid comparisons - the latter is a programming language, the former is implemented with a finite state machine that virtually any language can reproduce (think of the difference between a language and an algorithm). Python has a module dedicated to using regular expressions. So does Javascript. – Akshat Mahajan May 01 '16 at 03:11
  • Attempting to parse HTML with regular expressions [leads to madness](https://stackoverflow.com/questions/1732348/1732454#1732454). Your language of choice, whatever it is, already has at least one library _specifically_ for parsing HTML. Use it. – Kevin J. Chase May 01 '16 at 05:47

1 Answers1

0

As far as a regex, you could try:

&width=(\d+) for the width and &height=(\d+) for the height. Both of these will return one to unlimited digits following "&width=" or "&height=" in the first capture group

regex101.com is a good tool for building regexes. You can enter the regex you're thinking of and it puts out a nice explanation of what is actually happening

Sompom
  • 223
  • 2
  • 13
  • For hight i can Regex the +2, like Height=40$doregex[height2] and it will give me the right height since it goes 400 + 2 = 402. – S X May 01 '16 at 03:45
  • @SXhaferaj You can use parseint(string) to get the value as an integer type, then you can do anything you want with it – Sompom May 01 '16 at 03:47