马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
python request采集 正则 只能匹配一行,是啥情况
哪位大神帮我看一下,这正则 是哪里的问题,
代码如下,
我想匹配
SON_DATA.push(["48","603806","福斯特","196","9,838","-2,852","1247536.86","10.34","-3.31"]); 中的
603806 福斯特
里面有多行数据,代码我贴出来下面
这正则 应该怎么写才可以匹配到呢,谢谢import requests
import re
def get_html(url):
try:
resp = requests.get(url)
return resp.text
except Exception as e:
print(e)
if __name__ == "__main__":
url = 'http://fund.jrj.com.cn/action/fhs/list.jspa?thisReportDate=0'
html = get_html(url)
print(html)
pattern = re.compile(r'(?<=("))[\u4e00-\u9fa5]+(?=")',re.S)
searchObj = pattern.search(html)
print(searchObj.group())
import requests
import re
def get_html(url):
try:
resp = requests.get(url)
return resp.text
except Exception as e:
print(e)
if __name__ == "__main__":
url = 'http://fund.jrj.com.cn/action/fhs/list.jspa?thisReportDate=0'
html = get_html(url)
pattern = re.compile(r'JSON_DATA.push\(\["\d+","(\d{6})","(.*?)".*?\]\);',re.S)
searchObj = pattern.finditer(html)
for each in searchObj:
print(each.group(1),each.group(2))
|