python爬虫提取文本?

python爬虫提取文本?

问题描述:

<script type="text/javascript">
  window._global = {
      env: 'production',
      currentUser: [],
      xcx: {"id":"5089","hashid":"3f36b070b09c9c89a300c55ee651d3ed",}
</script>

爬虫怎么获取xcx里id的文本

import re

a = "<script type='text/javascript'>window._global = {env: 'production',currentUser: [],xcx: {'id':'5089','hashid':'3f36b070b09c9c89a300c55ee651d3ed',}</script>"

b = re.search('id.*?:\'(.*?)\'',a,re.S)
print(b.group(1))

用正则