Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Python 

Rewrite/Convert Javascript to Python possible?

Hello HF

I really suck at javascript and I am trying to focus on one language at a time and that is python, but I found a script I need for something and I was wondering if someone can help me rewrite it to Python if its possible.

The javscript/html:


if I understand the script correct it will start the javascript when the body is being loaded and then it will sent a RNKEY cookie.
What I would like is to make my python script generate the same value and print it out as a string, but I am not sure how to convert the script and I dont even know if its possible. 😧

Thanks in advance 😊
https://stackoverflow.com/questions/5871...n-possible

The answers in the comment section help out.

Je t'aime
[Image: fpZ5a5g.png]

(Apr 22, 2022 04:39 PM)-Scrub Wrote:  Jokes on you, I'm not smart enough to know what he's talking about.
(Nov 5, 2019 09:49 AM)Nachfolger Wrote:  javascript - Converting Javscript to Python possible? - Stack Overflow

The answers in the comment section help out.

Thanks I asked both places to get a faster response.
I'll read the comments and see if I can figure it out. 🤝
Here you go! 🤝

(Nov 7, 2019 11:56 AM)Kallu609 Wrote:  Here you go! 🤝


You are a life saver, will check this out when I am on my desktop PC !!
(Nov 7, 2019 11:56 AM)Kallu609 Wrote:  Here you go! 🤝

SNIP

I got an error, but all I did was to make sure the range() was an integer.
error:
TypeError: 'float' object cannot be interpreted as an integer

Fix:
PHP Code

<?php 
Change  
for i in range(7, m + 1, 30):
To for i in range(7, int(m + 1), 30): 
(Nov 16, 2019 06:22 AM)Beyonder Wrote:  I got an _error_, but all I did was to make sure the range() was an integer.
_error_:
TypeError: 'float' object cannot be interpreted as an integer

Fix:
PHP Code

<?php 
Change  for i in range
(7, m + 1, 30):
To for i in range(7, int(m + 1), 30): 

Oh yeah, I didn't really test it out. Glad you got it sorted out.
(Nov 17, 2019 08:08 AM)Kallu609 Wrote:  Oh yeah, I didn't really test it out. Glad you got it sorted out.

The javscript code and the python code does not give the same output.
Do you have an idea what might be wrong? :)
Thanks again for the help.
(Nov 17, 2019 08:10 AM)Beyonder Wrote:  The javscript code and the python code does not give the same output.
Do you have an idea what might be wrong? :)
Thanks again for the help.

No idea, I tried my best to code it 1:1, throw some console.logs in JS and prints in Python to see where the breaking point is. JS and Python share the same operators so the code is nearly identical.
(Nov 17, 2019 08:10 AM)Beyonder Wrote:  The javascript code and the python code does not give the same output.
Do you have an idea what might be wrong? :)
Thanks again for the help.

It is probably down to the IEEE 754 spec[1] used in javascript. This is why 0.1 + 0.2 === 0.30000000000000004 in javascript there is a great video[2] about it on low level javascript channel

[1] https://ieeexplore.ieee.org/document/30711
[2] https://www.youtube.com/watch?v=wPBjd-vb9eI

¸„»°'´¸„»°'´Vorticalbox `'°«„¸`'°«„¸
`'°«„¸¸„»°'´¸„»°'´`'°«„¸Scientia Potentia est ¸„»°'´`'°«„¸`'°«„¸¸„»°'´


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Python] by Bass_ReevesAug 20, 2023 01:44 AM 9 632 Aug 20, 2023 01:44 AM
Last Post: Lucky4L
[Shell] by newQueryAug 20, 2022 04:02 AM 0 95 Aug 20, 2022 04:02 AM
Last Post: newQuery
[Python] by FreddieXxMay 8, 2022 11:21 AM 2 144 May 8, 2022 11:21 AM
Last Post: FreddieXx