JavaScript Extract string html with regex on interval extract string html python,extract string from html,extract string

There is a public website with this in the source:

</div><script type="text/rocketscript">
function calculateIndexIncome() {
    var khs = $('#t9').val();
    var btcusd = $('#t9_1').val();
    var btckhs = $('#t9_2').val();
    var dayprofitperkhs = 0.00000018188885404454654
    var arr = btcusd.split(' ');
    btcusd = arr[0];

    var totalinvestmentusd = ((khs * btckhs) * btcusd).toFixed(2);
    var totalinvestmentbtc = (khs * btckhs).toFixed(8);
    var dailyincomebtc = (khs * dayprofitperkhs).toFixed(8);
    var dailyincomeusd = ((khs * dayprofitperkhs) * btcusd).toFixed(2);
    var monthlyincomebtc = (dailyincomebtc * 31).toFixed(8);
    var monthlyincomeusd = (dailyincomeusd * 31).toFixed(2);
    var breakevendays = (totalinvestmentusd / dailyincomeusd).toFixed(0);
    var monthlypercentage = ((100 / breakevendays) * 30).toFixed(2);

    $('#tl').html('Total KHS: ' + khs + '<br/>Total Investment: ' + totalinvestmentbtc + ' BTC ($' + totalinvestmentusd + ' USD)<br/><br/>Daily Income: ' + dailyincomebtc + ' BTC ($' + dailyincomeusd + ' USD)<br/>Monthly Income: ' + monthlyincomebtc + ' BTC ($' + monthlyincomeusd + ' USD)<br/><br/>Break Even In: ' + breakevendays + ' Days.<br/><br/>Monthly Rate: ' + monthlypercentage + '%');
}

I need to be able to extract two values: btckhs and dayprofitperkhs. if I look at page source, dayprofitperkhs is different everytime I refresh.

Edit:

Jimmy Chandra came up with this bookmarklet:

javascript:
setInterval(logging,60000);
w1 = window.open("https://scrypt.cc/index.php");
function logging(){
console.log (w1.$('#t9_2').val());
var re=/var\s*dayprofitperkhs\s*=\s*([0-9\.]+)\s*/gi;
var matches=re.exec(document.body.innerHTML);
console.log(RegExp.$1);
w1.location.href = 'https://scrypt.cc/index.php';
}

This works ALMOST perfectly. it gets the dayprofitperkhs, but only on the first interval. After that, the value is no longer updated, although t9_2 IS updated...

Anyone?

Answer:1

I don't know where that site is, so I am just running this against this SO question, but the following bookmarklet is getting me what I want...

As I mentioned in the comment, I use Regular Expression against the document body inner html and I am looking for dayprofitperkhs and capturing the numbers and decimal separator on the right side of the equal sign. Also trying to compensate for any extra spaces in between (\s*). RegExp.$1 gave me the number that I am looking for.

javascript:(function(){var re=/var\s*dayprofitperkhs\s*=\s*([0-9\.]+)\s*/gi;var matches=re.exec(document.body.innerHTML);console.log(RegExp.$1);}());

So your final bookmarklet should be something like:

javascript:
setInterval(logging,60000);
w1 = window.open("siteurl.com");
function logging(){
console.log (w1.$('#t9_2').val());
var re=/var\s*dayprofitperkhs\s*=\s*([0-9\.]+)\s*/gi;
var matches=re.exec(w1.document.body.innerHTML);
console.log(RegExp.$1);
w1.location.href = 'siteurl.com';
}
Answer:2

The variables in question are local variables within the calculateIndexIncome() function, so no, you can't access them from outside that function.

The reason the first one "works" is because you're not referring to the variable, but rather the value: $('#t9_2').val(). This is a jquery selector which finds the element with the ID t9_2 and grabs its value.

Answer:3

<html dir = rtl> <head> <title> </title> <meta HTTP-EQUIV="Content-language" CONTENT="ar"> <script type="javascript"> function d(...

<html dir = rtl> <head> <title> </title> <meta HTTP-EQUIV="Content-language" CONTENT="ar"> <script type="javascript"> function d(...

  1. check text html ratio
  2. checkbox text html
  3. check input text html
  4. sublime text check html syntax
  5. javascript check html text
  6. jasmine check html text
  7. sublime text check html
  8. check if text is html
  9. check if text is html c#
  10. check if text contains html
  11. check if text has html tags
  12. html check text length
  13. check if text contains html tags
  14. check if text contains html c#
  15. check if text is html swift
  16. js check text is html
  17. check bold text in html
  18. php check text html

I have a code, in three.js in console it says : DEPRECATED: Matrix4's .multiplyVector3() has been removed. Use vector.applyMatrix4( matrix ) or vector.applyProjection( matrix ) instead. But I have ...

I have a code, in three.js in console it says : DEPRECATED: Matrix4's .multiplyVector3() has been removed. Use vector.applyMatrix4( matrix ) or vector.applyProjection( matrix ) instead. But I have ...

newbie: writing jQuery on my own So I'm running into a snag with having jQuery add a class once the window has scrolled down after a set amount of pixels. To set a little background, the navbar ...

newbie: writing jQuery on my own So I'm running into a snag with having jQuery add a class once the window has scrolled down after a set amount of pixels. To set a little background, the navbar ...

  1. jquery window scroll position
  2. jquery window scroll function
  3. jquery window scroll to
  4. jquery window scrolltop
  5. jquery window scroll to element
  6. jquery window scroll not working
  7. jquery window scroll to top
  8. jquery window scroll to div
  9. jquery window scroll stop event
  10. jquery window scroll height
  11. jquery window scroll animate
  12. jquery window scroll up
  13. jquery window scroll down
  14. jquery window scroll offset top
  15. jquery window scroll bottom
  16. jquery window scroll not working in mobile
  17. jquery window scroll bottom of page
  18. jquery window scroll add class
  19. jquery window scroll ajax
  20. jquery window scroll position fixed

I am working to get response from SOLR using jquery. When I use the below code I got the error saying Typeerror:data is null When looked at the code in firebug, data in on_data function is null. I ...

I am working to get response from SOLR using jquery. When I use the below code I got the error saying Typeerror:data is null When looked at the code in firebug, data in on_data function is null. I ...

  1. retrieve results from multiple google pages
  2. retrieve results from mysql
  3. unable to retrieve results from nuget.org
  4. results from retrieve cream