xpath query for javascript [closed] - xpath

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 10 years ago.
<script type="text/javascript">
jwplayer('mediaspace').setup({
'flashplayer': 'http://www.vidok.co/s-static/v2/player-sp.swf',
'file': 'http://www.vidok.co/cfs-ak-snc6/2012-12-17457.mp4',
'image': '',
'logo': 'www.vidok.co/s-static/rsrc.php/logo-player-sp.png',
link': 'http://www.facefou.co/videos/watch-TqcLqlKBd2'
});
</script>
Hi I need the xpath query to get the "file : http://www.vidok.co/cfs-ak-snc6/2012-12-17457.mp4" from this script.
Thank's

Here's an approach:
"substring-before(substring-after(/script, '&apos;file&apos;: '),
'&apos;image&apos;')"
And if you really want the "file : " at the beginning, use concat('file : ', theaboveexpression).
But if you ask me, XPath is not the best tool for this job.
Better to use something like regular expressions to parse the Javascript.

Related

How to match specific number from text - Ruby regex [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 9 years ago.
id="profile_photo_link" href="/photo83085640_283973341" onclick="return showPhoto('83085640_283973341', 'album8308564
0_0/rev',
{temp:{base:"http://cs301701.vk.me/v301701640/",x_:["181d/N_1czOIgH0s",556,313]},
jumpTo:
{z: 'albums83085640'}}, event)">
<img width="200" height="205" src="http://cs301701.vk.me/v301701640/4a03/mfKV3wOhrqU.jpg
" alt="Сергей On-line Консультации Василюк">
How to match this(83085640) number from text above by ruby regex ? The Start of regex must be after showPhoto(' text and ends at this point _ after numbers
Please help!
You simply need to do the following:
my_text = "showPhoto('83085640_283973341',"; #Input string. I'm only using a part of it here for convenience.
pat = /showPhoto\('(\d*)_/; #The Regexp pattern as per your requirements.
puts(pat.match(my_text)[1]);
Output:
83085640

How do I execute a ruby script with a method but no class? [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 10 years ago.
I have:
def is_valid_cool_string(str)
...
end
And I want to write something like is_valid_cool_string("Foobar") at the bottom of the file to do this. Is there like a main method or something like that?
Thanks!
You don't need anything to make this work. :)
Don't forget to print the result if the method returns something.
puts is_valid_cool_string("Foobar")
or something like
puts "Is valid: #{is_valid_cool_string("Foobar").inspect}"

Creating model methods [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 9 years ago.
I want to create a method which will give me the user's full name.
the user has a first_name and a sur_name attribute.
I am trying to do something like
def fullname
"#{self.first_name} #{self.sure_name}"
end
but it gives me a method missing error when I try to do #user.fullname
am I missing something?
You have a typo: your method calls sure name (with an "e"), and you want sur name (without an "e").

Constructing Ruby's regular expression [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 10 years ago.
I need some guidance on how to do the following..
Let say I have this string below
s= {"name":testName,"age":20}
how should I construct my regular expression in ruby, such that I am able to get "testName"
Thank you in advance
The data you have is a JSON string. You should not parse it with a regular expression, but parse it into an object and then access the name property.
I am not a Ruby dev, but you can do so if you have the JSON gem.
I agree with Jason about using JSON, but if you really can't...
1.9.3p194 > s= '{"name":testName,"age":20}'
=> "{\"name\":testName,\"age\":20}"
1.9.3p194 > s =~ /"name":(.*?)(,"|})/
=> 1
1.9.3p194 > puts $1
testName
Note that this is evil and wrong and will probably hurt little kittens... use JSON to save the kittens.

jquery ajax passing more than one parameter [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 10 years ago.
I am trying to pass two request parameters by ajax using jquery. The following is what I do:
function querySummary(){
$.ajax({
type:"POST",
url:"internalSummary.action",
data:{starttime:$("#starttime").val(),endtime:${"#endtime"}.val()},
success: function(data) {
$("#hello").html( data );
}
});
}
I am trying to pass starttime and endtime two parameters, but get
Uncaught SyntaxError: Unexpected token ILLEGAL
Can anyone give some suggestions on how to solve this?
Thanks alot!
You're using curly braces instead of parentheses on the second jquery select. data should be as follows:
{starttime:$("#starttime").val(),endtime:$("#endtime").val()}
The names of the values can be quoted or unquoted; javascript assumes they are names and not variables.

Resources