1

https://www2.newegg.com/Common/Ajax/Navigation.aspx?callback=Web.Template.RolloverMenu2015.JsonpCallBack

The following is the output from the above URL. I want to extract the string in the argument of Web.Template.RolloverMenu2015.JsonpCallBack(). Notice there are escapes. I am not sure what is the best way to handle a string with escapes. Does anybody know what is the best way to extract the original string (i.e, in the unescaped from) from the output from that URL (in python and in nodejs)? Thanks.

Web.Template.RolloverMenu2015.JsonpCallBack("<nav class=\"btn...
1
  • 1
    with or without the html code? Commented Sep 13, 2019 at 14:05

1 Answer 1

1

JSONP is just JSON, but wrapped in a function call so that it can be treated like an HTML <script>. If you strip off everything up to the first paren (Web.Template.RolloverMenu2015.JsonpCallBack(), then also remove the last paren, you should be able to proceed just as you would with regular JSON, using something like this: https://www.w3schools.com/python/python_json.asp

The standard json.loads() knows all about how to handle all of the escaped characters and the rest of JSON syntax.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.