title: calling a script function using requests_html python
body: <p>I'm looking to scrape some data from the following web site: <a href="https://www.atptour.com/en/scores/stats-centre/archive/2022/414/MS024" rel="nofollow noreferrer">https://www.atptour.com/en/scores/stats-centre/archive/2022/414/MS024</a></p>
  <p>The underlying match statistics are loaded by the following javacript:</p>
  <pre><code>&lt;script nonce=&quot;5e824960-ee11-4894-b33c-9b0a25ace2d3&quot; type=&quot;text/javascript&quot;&gt;
          var initial = {
              matchStatsContainer : &quot;#matchStatsContainer&quot;,
              matchStatsTemplate : &quot;#matchStatsTemplate&quot;,
              currentMatchStatsToggle : &quot;currentMatchStatsButton&quot;,
              liveMatchUrl : &quot;&quot;,
              setPhrase : &quot;set&quot;,
              matchPhrase : &quot;match&quot;,
              liveMatchDetails : {
                  isMatchLive : 'True',
                  eventId : '414',
                  matchId : 'MS024'
              }
  
          }
          require([&quot;modules/modal/modalScoresMatchStats&quot;],
              function (ModalScoresMatchStats) {
                  return new ModalScoresMatchStats({
                      matchStatsContainer : &quot;#match-stats-container&quot;,
                      matchStatsTemplate : &quot;#matchStatsTemplate&quot;,
                      currentMatchStatsToggle : &quot;currentMatchStatsButton&quot;,
                      liveMatchUrl : &quot;&quot;,
                      setPhrase : &quot;set&quot;,
                      matchPhrase : &quot;match&quot;,
                      liveMatchDetails : {
                          isMatchLive : 'True',
                          eventId : '414',
                          matchId : 'MS024'
                      }
                  });
              });
      &lt;/script&gt;
  </code></pre>
  <p>I am using the following code with script set to:</p>
  <pre><code> var initial = { .....
        liveMatchDetails : {
                          isMatchLive : 'True',
                          eventId : '414',
                          matchId : 'MS024'
                      }
                  });
              });
  
  
  
  html = HTML(html=str(match_stats_html), async_=True)
  val = html.render(script=script, reload=False)
  </code></pre>
  <p>I get the following error:</p>
  <p>ElementHandleError: Evaluation failed: ReferenceError: require is not defined
  at <strong>pyppeteer_evaluation_script</strong>:16:9</p>
  <p>When I remove require from the script I get the following error:</p>
  <p>ElementHandleError: Evaluation failed: SyntaxError: Unexpected token (</p>
  <p>Any ideas on how  I could execute the script and obtain the data returned by the results?</p>
  <p>Thanks</p>