So I'm trying to get a value from a object in html. I've found out how to get the value, but there's extra stuff being added to it that I don't want.
I've tried using .split() and groups but none of those have done anything.
html = r.text
checkouttoken = re.search('DF_CHECKOUT_TOKEN = (.*?);', html, re.S)
print(checkouttoken.group(0))
Expected:
27f37949bb8a76ede81508c8c1b750c8
Actual:
< iframe srcdoc="<script>!function(){var e=function(e){var t={exports:{}};return e.call(t.exports,t,t.exports),t.exports},r=function(){fun
DF_CHECKOUT_TOKEN = "27f37949bb8a76ede81508c8c1b750c8";
Do group(1)
. group(0)
is all of the matched text, group(1)
is the first group that you captured.
Also, if you don't want the quotations in the result, you will need to add the quotations to the regex, outside of the capture group: 'DF_CHECKOUT_TOKEN = "(.*?)";'