php - Get embedded values in javascript function on HTML Page -


I am using php and trying to get value in javascript function. The HTML page contains the following JavaScript:

  & lt; Script type = "text / javascript" & gt; Function Show (q) {if (q.length & gt; 0) {if (q.indexOf ("tid")> -1) {location.href = "map.jsp?" + Q; } And {location.href = "listmap.jsp?" + Q; } } return false; } $ (Function () {$ ("# map"). GoMap ({Latitude: -35.331415, Longitude: 14 9.131851, Maitrippe: 'Roadmap', Scrollwell: False, Zoom: 11, Marker: [{Latitude: -35.192103 , Longitude: 14 9.332313, icon: 'images / m / marker1.png', html: {content: 'Loading ...', Ajax: 'mapinfo.jsp? Sid = 9057'}}]   

I have latitude and longitude which is: -35.331415 and 14 9.131851

I'm not sure the values ​​of the other values ​​(3 and 4th rows Getting needed) How to use personal values ​​...

EDIT: I am using PHP to save these values ​​in the variable and later I write it in a CSV file. I am currently receiving this code (here is a snippet ) Everything else on other pages

  & lt ;? php $ ch = curl_init ("http://pvoutput.org/listmap.jsp?sid=312"); curl_setopt ($ CH, CURLOPT_RETURNTRANSFER, $ Cl = curl_exec ($ ch); $ dom = new dOMDocument (); $$ dom - & gt; Load HTML ($ cl); $ Lat_data = $ dom - & gt; GetElementsByTagName ("script"); Print_r ($ lat_data -> item (1)); Edit 2: I've fixed all the problems by doing this:  
  $ Lat_data = $ dom - & gt; GetElementsByTagName ("script"); $ Content = $ lat_data - & gt; Items (10) - & gt; TextContent; $ Regex = "/ Latitude: ([^ \ b,] *) /"; If (preg_match ($ regex, $ content, $ value)) resonate {$ values ​​[1]; $ Regex2 = "/ longitude: ([^ \ b,] *) /"; } If (preg_match ($ regex2, $ contents, $ values2)) {values ​​resonate to $ 2 [1]; }       Want  
  $ content = $ lat_data - & gt; Item (1) - & gt; Once you have obtained the content, you can parse it by using the regex expression to get it  
  $ regex = "/ latitude: ([^ \ b \ n] *) ( | | \ N) *, Longitude: ([^ \ b \ n,] *) / "; If (preg_match ($ regex, $ content, $ value)) {echo 'latitude:'. $ Values ​​[0]; Echo 'longitue:' $ Values ​​[2]; Regex explanation (test):  
  • "Latitude:" finds:
  • Then we get the first group (), [^ \ B \ n] * means
  • Anything between the latitude value and 'longitude:'
  • Next search ", longitude:"
  • The last one As the third group I said ',' so that it is not empty between longitude and ',' it still works. '' This regex description is a bit messy, more detailed For interpretation Please check the test link.

    I have not tested it, so some syntax errors may occur, but the idea is;)

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -